473,813 Members | 3,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SetParent() on a control

I am creating a ListView through CreateWindowEx( ). It works fine when
I create it as a child window as so:

hControl = CreateWindowEx( WS_EX_CLIENTEDG E, WC_LISTVIEW, NULL,
WS_VISIBLE | WS_CHILD | LVS_REPORT, 300, 100, 100, 100, hWnd, NULL,
NULL, NULL);

However, I want to create the control with no parent, then add it to
the parent form later. Something like this...

hControl = CreateWindowEx( WS_EX_CLIENTEDG E, WC_LISTVIEW, NULL,
LVS_REPORT, 300, 100, 100, 100, NULL, NULL, NULL, NULL);

SetParent(hCont rol, hWnd);

The drawing of the ListView in that code goofs up the window drawing.
I played arround a bit and came up with this:

hControl = CreateWindowEx( WS_EX_CLIENTEDG E, WC_LISTVIEW, NULL,
WS_POPUP, 100, 100, 100, 100, NULL, NULL, NULL, NULL);

SetParent(hCont rol, hWnd);

dwStyle = GetWindowLong(h Control, GWL_STYLE);
dwStyle &= ~(WS_CLIPSIBLIN GS | WS_POPUP);
dwStyle |= WS_CHILD | WS_VISIBLE | LVS_REPORT;

SetWindowLong(h Control, GWL_STYLE, dwStyle);
ShowWindow(hCon trol, SW_SHOW);

This works for the drawing, but if you right click in the header area,
you will get a stack error. Any ideas?

Feb 1 '06 #1
3 5752

mi***@miben.net wrote:
I am creating a ListView through CreateWindowEx( ). It works fine when
I create it as a child window as so:

hControl = CreateWindowEx( WS_EX_CLIENTEDG E, WC_LISTVIEW, NULL,
WS_VISIBLE | WS_CHILD | LVS_REPORT, 300, 100, 100, 100, hWnd, NULL,
NULL, NULL);

However, I want to create the control with no parent, then add it to
the parent form later. Something like this...

hControl = CreateWindowEx( WS_EX_CLIENTEDG E, WC_LISTVIEW, NULL,
LVS_REPORT, 300, 100, 100, 100, NULL, NULL, NULL, NULL);

SetParent(hCont rol, hWnd);

The drawing of the ListView in that code goofs up the window drawing.
I played arround a bit and came up with this:

hControl = CreateWindowEx( WS_EX_CLIENTEDG E, WC_LISTVIEW, NULL,
WS_POPUP, 100, 100, 100, 100, NULL, NULL, NULL, NULL);

SetParent(hCont rol, hWnd);

dwStyle = GetWindowLong(h Control, GWL_STYLE);
dwStyle &= ~(WS_CLIPSIBLIN GS | WS_POPUP);
dwStyle |= WS_CHILD | WS_VISIBLE | LVS_REPORT;

SetWindowLong(h Control, GWL_STYLE, dwStyle);
ShowWindow(hCon trol, SW_SHOW);

This works for the drawing, but if you right click in the header area,
you will get a stack error. Any ideas?


None of this is standard C++. There's no guarantee that people here
will recognise any of your code. You'll have much better luck asking in
a Windows programming newsgroup.

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Gavin Deane

Feb 1 '06 #2
mi***@miben.net wrote:
I am creating a ListView through CreateWindowEx( ). It works fine when
[...]

However, I want to create the control with no parent, then add it to
the parent form later. Something like this...

[...]

This works for the drawing, but if you right click in the header area,
you will get a stack error. Any ideas?


You're in a wrong newsgroup. Try 'microsoft.publ ic.vc.mfc'.

V
--
Please remove capital As from my address when replying by mail
Feb 1 '06 #3
ya, i found it, thanks. sorry for the bad post.

Feb 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
545
by: Raghavendran Muraleetharan | last post by:
I have a requirement where I need to embed a VB 6 forms application into .Net forms application. Basically the new .Net application would act as a wrapper application and would control the embedded VB 6 application. I tried to start the VB 6 in a separate process from dot net app and acquired the handle of the handle to the main window of the process. Next I used to use Win32 API function SetParent to set the parent of the VB 6...
6
3420
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get sized strangely using the .RTFHeight property of the control. Specifically, lines of text get cut off the bottom of the control when I use the code provided in the sample report on the lebans.com site. It seems that when there is Chinese text,...
6
11305
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
2
3634
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
2
4934
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is being updated by some other process through remoting. When the page loads, I init the tree, and in my browser I can see the initialized tree. The problem is that every time that I receive update to tree from the remote process,
15
6541
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
0
1606
by: clarionprogrammer | last post by:
Problem info: 1. My application runs in AppDomain1. 2. My plugin runs in AppDomain2. I am able to place the plugin form inside an application panel via the SetParent() API call. However, once SetParent() is used, the menu strip on the plugin ceases to function: It will no longer drop down the menu list once it is selected.
7
7343
by: Matt | last post by:
Hello to all, I'm having something of a problem with the WinAPI call SetParent. Here's the scenario. I am trying to take an existing program, and run it within my own window. I can make this happen, the code looks like this: / Remove border and whatnot long style = GetWindowLong(appWin, GWL_STYLE); long new_style = WS_CHILD | WS_VISIBLE;
0
1550
by: ramveers | last post by:
I ma creating a toolbar for IE. I am setting a parent of toolbar dynamically by using SetParent method of window API. My problem is that SetParent method does not set parent and return zero(IntPtr). By using last error code, its gives 1400 (Means Invalid Handle). I check that handle of toolbar and handle of new parent are valid, but previous parent of toolbar handle has been invalid. Now i want to assign new parent of toolbar but SetParent...
0
9609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10426
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10141
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9225
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5707
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3030
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.