Skip to main content
gamedev.net
🔒 Locked

Window Cannot Be Selected

Started by Ademan555 Jan 10, 2004 at 3:08 PM 11 replies 1.2k views
Original Post
Ademan555
Ademan555
In my program (a newbie chat client) im creating a window when someone usess the "connect" menu then goes to the "client" option... This window is created in the WndProc but when its created it cannot be selected, the styles i used were WS_VISIBLE|WS_SYSMENU|WS_OVERLAPPED anyone have any ideas? -Dan Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Thunder_Hawk
Thunder_Hawk
Make sure you handle the messages to the window properly. It sounds like you are somehow just ignoring the WM_ACTIVATE message.

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Forma
Ademan555
Ademan555
Well i let it go right back to the DefWindowProc(), is that a bad thing?

-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Thunder_Hawk
Thunder_Hawk
Hmmm, never mind then...I''m not overly versed in the Win32 API (just enough to do what I want to). You might find some help at Winprog.org.

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Forma
Ademan555
Ademan555
Well thanx though, anyone else>?


-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Nytegard
Nytegard
It sort of sounds like you're using a modal dialog. Are you? If this is the case, the window you created, not being a child window, would be unable to be selected.

At the same time, what WindowProc did you use for the window you want to be selected when you created it? That really shouldn't be too much of a concern if you used the same one though, because the HWND would be pointing to the other window.

(Some code on your windows creation would be nice to see though.)

[edited by - Nytegard on January 10, 2004 6:20:32 PM]
Ademan555
Ademan555
I dunno what you mean by modal dialog, i created both windows with CreateWindow(), but a child window is limited to the parent''s client area, and also, it cant have a caption or anything, i just want a normal second window created when the first recieves a certain command.

-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Nytegard
Nytegard
You need to show a little code, because this code (which I think you mean), works fine:


#include <windows.h>

#define NAME1 "A window"
#define TITLE1 "A window"

#define NAME2 "A second window"
#define TITLE2 "A second window"

HWND hWnd;
HWND secondhWnd;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);

LRESULT CALLBACK SecondWndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);

ATOM MyRegisterClass(HINSTANCE hInstance, LPCSTR name);
ATOM MyRegisterClassSecond(HINSTANCE hInstance, LPCSTR name);


BOOL InitApp(HINSTANCE hInstance, int nCmdShow, LPCSTR name, LPCSTR title)
{

// Create a window


hWnd = CreateWindow(name,
title,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
0,
hInstance,
NULL);

if (!hWnd)
return FALSE;
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}

BOOL InitAppSecond(HINSTANCE hInstance, int nCmdShow, LPCSTR name, LPCSTR title)
{

// Create a window


secondhWnd = CreateWindow(name,
title,
WS_VISIBLE|WS_SYSMENU|WS_OVERLAPPED,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
0,
hInstance,
NULL);

if (!secondhWnd)
return FALSE;
ShowWindow(secondhWnd, nCmdShow);
UpdateWindow(secondhWnd);
return TRUE;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HINSTANCE hInstance;

hInstance = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);

switch (message)
{
case WM_CREATE:
MyRegisterClassSecond(hInstance, NAME2);

if( FAILED( InitAppSecond(hInstance, SW_SHOW, NAME2, TITLE2) ) )
return 0;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

LRESULT CALLBACK SecondWndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd, message, wParam, lParam);
}


ATOM MyRegisterClass(HINSTANCE hInstance, LPCSTR name)
{
WNDCLASS wc;

// Set up and register window class

wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH )GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = name;
return RegisterClass(&wc);
}

ATOM MyRegisterClassSecond(HINSTANCE hInstance, LPCSTR name)
{
WNDCLASS wc;

// Set up and register window class

wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = SecondWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH )GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = name;
return RegisterClass(&wc);
}

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
MyRegisterClass(hInstance, NAME1);

if( FAILED( InitApp(hInstance, nCmdShow, NAME1, TITLE1) ) )
return 0;

// Main message loop:

while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return (int)msg.wParam;
}

Ademan555
Ademan555
Is it possibly a bad thing that i registered the second class from the WinMain and then created the window in teh wnd proc?

-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Nytegard
Nytegard
It doesn''t matter where you registered it, as long as you registered it before you created the window. Then again, if it failed registration, it wouldn''t even show.

It still would be helpful to show some code, as there only is so much people can think of with limited info.

As stated, probably you''re mishandling a WM_ACTIVATE, or I still think you''re using a modal dialog somewhere.
Ademan555
Ademan555
alright i just figured source wouldnt be necessary from this one, but alright

WndProc1

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
static SockParams SP = {0};

switch(uMessage)
{
case WM_CREATE:
CreateWindow("EDIT", NULL, WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE, 0, 0, 512, 256, hWnd, (HMENU)ID_DISPLAYEDIT, NULL, NULL);
CreateWindow("EDIT", NULL, WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE, 0, 256, 512-128, 256, hWnd, (HMENU)ID_SENDEDIT, NULL, NULL);
CreateWindow("BUTTON", "Send", WS_CHILD|WS_VISIBLE|WS_BORDER, 512-128, 256, 128, 256, hWnd, (HMENU)ID_SENDBUTTON, NULL, NULL);
break;
case WM_DESTROY:
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_MENUSERVER:
_beginthread(SERVERSTARTUP, 0, (void*)&SP);
AddToEdit(GetDlgItem(hWnd, ID_DISPLAYEDIT), "\r\r\nNOTICE: Starting Up As Server", 32);
break;
case ID_MENUCLIENT:
ClientConnect(&SP);
break;
case ID_SENDBUTTON:
if (SP.bConnected)
{
send(SP.Sock, hWnd);
}
else
{
AppendWndText(hWnd);
AddToEdit(GetDlgItem(hWnd, ID_DISPLAYEDIT), "\r\r\nERROR: Not Connected\r\r\n", 26);
}
break;
case ID_DISPLAYEDIT:
case ID_SENDEDIT:
break;
}
break;
case WM_KEYDOWN:
if (wParam==VK_RETURN)
{
send(SP.Sock, hWnd);
}
break;
default:
return DefWindowProc(hWnd, uMessage, wParam, lParam);
}
return 0;
}

WndProc2

LRESULT CALLBACK IPProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
switch(uMessage)
{
case WM_CREATE:
CreateWindow("EDIT", NULL, WS_CHILD|WS_VISIBLE|ES_NUMBER, 4+2, 4, 32, 12, hWnd, (HMENU)ID_ED1, NULL, NULL);
SendMessage(GetDlgItem(hWnd, ID_ED1), EM_SETLIMITTEXT, 2, NULL);
CreateWindow("EDIT", NULL, WS_CHILD|WS_VISIBLE|ES_NUMBER, 8+32+2, 4, 32, 12, hWnd, (HMENU)ID_ED2, NULL, NULL);
SendMessage(GetDlgItem(hWnd, ID_ED2), EM_SETLIMITTEXT, 2, NULL);
CreateWindow("EDIT", NULL, WS_CHILD|WS_VISIBLE|ES_NUMBER, 12+64+2, 4, 32, 12, hWnd, (HMENU)ID_ED3, NULL, NULL);
SendMessage(GetDlgItem(hWnd, ID_ED3), EM_SETLIMITTEXT, 2, NULL);
CreateWindow("EDIT", NULL, WS_CHILD|WS_VISIBLE|ES_NUMBER, 16+96+2, 4, 32, 12, hWnd, (HMENU)ID_ED4, NULL, NULL);
SendMessage(GetDlgItem(hWnd, ID_ED4), EM_SETLIMITTEXT, 2, NULL);
CreateWindow("BUTTON", "&Accept", WS_CHILD|WS_VISIBLE, 16, 8+12+4, 128-8, 24, hWnd, (HMENU)ID_BOK, NULL, NULL);
break;
case WM_COMMAND:
if (LOWORD(lParam)==ID_BOK)
{
//******//

//GET IP//or not, thats an old comment

//******//i dont wanna do it from here anymore

}
break;
case WM_DESTROY:
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, uMessage, wParam, lParam);
}
return 0;
}
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Ademan555
Ademan555
Sri for the double post but i want to push this back up to the top since i posted my code...

-Dan

Yes I realize im a n00b...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Ademan555
Ademan555
Ill try once more to ressurect this thread, plz help...
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.