C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-29-2009, 11:53 AM   #1
Not stupid, just stupider
 
yaya's Avatar
 
Join Date: May 2007
Location: Earthland
Posts: 151
Thumbs up Empty child window...

I'm trying to implement a child window so I can put buttons and such in it, though things aren't going to plan. This is what I've got:

Code:
hChild = CreateWindowEx( NULL, "", NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hMainWindow, (HMENU)ID_CHILD, GetInstance(), NULL );
The problem is, hChild is always 0 (because it failed). I'm guessing the problem is that I don't have a WNDCLASSEX in there, but I want it to be empty. So what's wrong? Or am I going about this the complete wrong way?

Cheers.

EDIT: Sorry, I should've explained the situation more. What I'm trying to do is implement pages in my Tab Controls. I've got the tabs appearing and running fine, but I'm thinking I will add a child window for each page. When the user clicks on a tab, I'll use ShowWindow() to hide the old child window and display the new one. I've figured this would be a pretty good way of doing it (or is it?). So, more or less, how do you implement a child window into a tab, so that I can put in my other controls on the page?

Last edited by yaya; 10-29-2009 at 04:45 PM.
yaya is offline   Reply With Quote
Old 10-29-2009, 12:51 PM   #2
Registered User
 
Join Date: Mar 2005
Location: Juneda
Posts: 224
Try the DialogBox instead, just declare a template for the window (not necessary the inside controls) and a procedure for that window. Something like that, first setup the template on the resource file:

Code:
MYSAMPLEWINDOW DIALOG DISCARDABLE  0, 0, 100, 100
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION NOMAPP
FONT 8, "MS Sans Serif"
BEGIN
END
Notice that 'MYSAMPLEWINDOW' will be the window identifyer, so define it on your definitions file:

Code:
#define MYSAMPLEWINDOW 1000
Declare a procedure for that window:

Code:
BOOL CALLBACK MySampleWindowProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
    {
    default: return 0;
    }
return 1;
}
In the window's procedure you'll have to check the WM_ messages to respond to the window's events. Finally create the dialog:

Code:
DialogBox(GetModuleHandle(0),MAKEINTRESOURCE(MYSAMPLEWINDOW),hwnd,MySampleWindowProc);
Take a look to the win32 prog reference, or in the msdn to see more about that function, and check oput also the function DialogBoxParam.

Still another way to do it is creating your own window class, you can find more about that on catch22 (I'm not sure the section's name, but was something like custom controls from scratch).

Hope that helps
Niara
Niara is offline   Reply With Quote
Old 10-29-2009, 04:45 PM   #3
Not stupid, just stupider
 
yaya's Avatar
 
Join Date: May 2007
Location: Earthland
Posts: 151
Sorry, I should've explained the situation more. What I'm trying to do is implement pages in my Tab Controls. I've got the tabs appearing and running fine, but I'm thinking I will add a child window for each page. When the user clicks on a tab, I'll use ShowWindow() to hide the old child window and display the new one. I've figured this would be a pretty good way of doing it (or is it?). So, more or less, how do you implement a child window into a tab, so that I can put in my other controls on the page?
yaya is offline   Reply With Quote
Old 10-29-2009, 11:16 PM   #4
train spotter
 
Join Date: Aug 2001
Location: near a computer
Posts: 3,359
That is the way I do it.

I 'draw' the dialog in the IDEs resource edtior, [the bit you have missed]
create all the child dilalogs when the TAB is created
and hide/show the appropriate one on TAB selection change.
__________________
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche

"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best

"If you are going through hell....keep going."
Winston Churchill
novacain is offline   Reply With Quote
Old 10-30-2009, 06:10 AM   #5
Registered User
 
Join Date: Mar 2005
Location: Juneda
Posts: 224
Ok, I was thinking you needed a popup. As novacain said, that's also the way I do it.

Niara
Niara is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pong is completed!!! Shamino Game Programming 11 05-26-2005 10:50 AM
Adding colour & bmps to a Win 32 Window?? carey_sizer Windows Programming 4 09-04-2004 05:55 PM
Child window inside child window Magos Windows Programming 13 04-20-2004 06:51 AM
Child window with active (highlighted) title bar: Possible? JasonD Windows Programming 7 10-16-2003 06:43 AM
opengl code not working Unregistered Windows Programming 4 02-14-2002 10:01 PM


All times are GMT -6. The time now is 05:40 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22