473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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_CLIENTEDGE, 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_CLIENTEDGE, WC_LISTVIEW, NULL,
LVS_REPORT, 300, 100, 100, 100, NULL, NULL, NULL, NULL);

SetParent(hControl, 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_CLIENTEDGE, WC_LISTVIEW, NULL,
WS_POPUP, 100, 100, 100, 100, NULL, NULL, NULL, NULL);

SetParent(hControl, hWnd);

dwStyle = GetWindowLong(hControl, GWL_STYLE);
dwStyle &= ~(WS_CLIPSIBLINGS | WS_POPUP);
dwStyle |= WS_CHILD | WS_VISIBLE | LVS_REPORT;

SetWindowLong(hControl, GWL_STYLE, dwStyle);
ShowWindow(hControl, 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 5719

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_CLIENTEDGE, 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_CLIENTEDGE, WC_LISTVIEW, NULL,
LVS_REPORT, 300, 100, 100, 100, NULL, NULL, NULL, NULL);

SetParent(hControl, 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_CLIENTEDGE, WC_LISTVIEW, NULL,
WS_POPUP, 100, 100, 100, 100, NULL, NULL, NULL, NULL);

SetParent(hControl, hWnd);

dwStyle = GetWindowLong(hControl, GWL_STYLE);
dwStyle &= ~(WS_CLIPSIBLINGS | WS_POPUP);
dwStyle |= WS_CHILD | WS_VISIBLE | LVS_REPORT;

SetWindowLong(hControl, GWL_STYLE, dwStyle);
ShowWindow(hControl, 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.public.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
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...
6
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...
6
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"...
2
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
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...
15
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...
0
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,...
7
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...
0
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)....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.