Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I cant get my buttons to appear in my screen

Status
Not open for further replies.

lemming999

Programmer
Mar 11, 2002
12
0
0
IE
As you can see i dont use the WM_PAINT function because this code is more efficient for drawing to screen for my program. However this button here won't appear on screen.

I'm a really novice programmer and i'm trying to tweak another program so i dont know where I am going wrong.
hwndMagnify is declared globally, and the drawmap function completely clears the screen and fills in the screen

while( WM_QUIT != msg.message )
{
if( g_bActive )
bGotMsg = PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE );
else
bGotMsg = GetMessage( &msg, NULL, 0U, 0U );
if( bGotMsg )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}

else
{
ShowWindow(hwndMagnify, SW_SHOW);
m.drawMap(d.getHdc(),cxClient,cyClient);
B.DrawAllBuildings(d.getHdc(), cxClient, cyClient);

if (sim != NULL)
{
sim->update();
sim->drawVehicles(d.getHdc(),cxClient,cyClient);

}
d.pageFlip(cxClient,cyClient);

}
}
.............................
.............................

case WM_CREATE:
hdc = GetDC (hWnd);
hwndMagnify = CreateWindow("button", "Rotate 90°",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 55, 1,40 , 1, hWnd, HMENU(IDC_STUC1),hInst, NULL) ;

return 0;
 
Some questions:
1. What are m, B, sim and d? Where are they created? Dou You check if they exist and initialized before You use them?
2. What is hWnd? Does it exists before You get it's DC?
3. Is hInst the Handle of right module?
And I think, there are (may be) some Errors too:
1. You use GetDC() (may be You use GetDC() in getHdc() too?) and do not use ReleaseDC().
It may create problems by drawing.
2. ShowWindow(hwndMagnify, SW_SHOW); does not allways draw any window, normally a window will be redrawn with OnDraw() - Function.
3. Some Parameters of CreateWindow("button", "Rotate 90°",WS_CHILD | WS_VISIBLE |
BS_PUSHBUTTON, 55, 1,40 , 1, hWnd, HMENU(IDC_STUC1),hInst, NULL) ;
are wrong:
"button" - is this class really registered?
55, 1,40 , 1, - do You really wish to use Button with height 1 Point? Can it be shown at all?
HMENU(IDC_STUC1) - do You really need Menu in Your Button?
and with last arg. NULL - it should be a Pointer to right CREATESTRUCT.
I hope, this can help You.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top