Click here to Skip to main content
15,883,127 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: _argv[] proglems Pin
hlmechanic21-Sep-06 12:09
hlmechanic21-Sep-06 12:09 
GeneralRe: _argv[] proglems Pin
David Crow22-Sep-06 3:02
David Crow22-Sep-06 3:02 
AnswerRe: _argv[] proglems Pin
hlmechanic21-Sep-06 17:01
hlmechanic21-Sep-06 17:01 
QuestionRe: _argv[] proglems Pin
David Crow22-Sep-06 3:16
David Crow22-Sep-06 3:16 
AnswerRe: _argv[] proglems Pin
hlmechanic22-Sep-06 4:06
hlmechanic22-Sep-06 4:06 
QuestionRe: _argv[] proglems Pin
David Crow22-Sep-06 5:21
David Crow22-Sep-06 5:21 
AnswerRe: _argv[] proglems Pin
hlmechanic22-Sep-06 5:42
hlmechanic22-Sep-06 5:42 
Questionwin32 API - How to use a button Pin
gunner_uk200021-Sep-06 6:13
gunner_uk200021-Sep-06 6:13 
I have used the following tutorials to get a window on the screen.

http://www.zeuscmd.com/tutorials/win32/05-CreatingWindows.php

This is fine as the person writing it give pretty good explainations of what he does.

I have been unable to fine out how to put a button onto this screen as i cannot find and decent guides for this. Microsofts documentation is quite horrid, poorly orgainized and spits huge reams of code at you with little in the way of commenting.

Look at the java documentation for how it should be done tbh.

Now that mini rant is over this is my code that i copied from MSDN for putting a button on the screen.

<br />
	hwndButton = CreateWindow( <br />
    "BUTTON",   // predefined class <br />
    "Do Something",       // button text <br />
    WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,  // styles <br />
 <br />
    // Size and position values are given explicitly, because <br />
    // the CW_USEDEFAULT constant gives zero values for buttons. <br />
    10,         // starting x position <br />
    10,         // starting y position <br />
    130,        // button width <br />
    20,        // button height <br />
    hwnd,       // parent window <br />
    NULL,       // No menu <br />
    (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), <br />
    NULL);      // pointer not needed <br />


It does just that and its is one of the better commented examples and i have put two buttons on the screen.

What i cannot work out is how to identify the buttons when the message handles method is called.

this is coded as follows:

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
	switch(msg)<br />
	{<br />
	case WM_CLOSE :<br />
		DestroyWindow(hwnd);<br />
		break;<br />
<br />
	case WM_DESTROY :<br />
		PostQuitMessage(0);<br />
		break;<br />
	case WM_KEYDOWN:<br />
		if(wParam == 'U'){<br />
			MessageBox(NULL, "U Pressed", "U", MB_OK);<br />
		}<br />
		break;<br />
	case WM_KEYUP:<br />
		if(wParam == 'L'){<br />
			MessageBox(NULL, "L Released", "L", MB_OK);<br />
		}<br />
	<br />
	case BN_CLICKED:<br />
		if(true) //have no idea what to put in here to work out which button was press.<br />
			MessageBox(NULL, "left ", "L", MB_OK);<br />
		else<br />
			MessageBox(NULL, "right ", "L", MB_OK);<br />
	}<br />
	return DefWindowProc(hwnd, msg, wParam, lParam);<br />
}


Anyone have any ideas? or any links to decent guides to win32 programming? (which don't just tell you have to get visual studio to generate the code for you)
AnswerRe: win32 API - How to use a button Pin
David Crow21-Sep-06 6:56
David Crow21-Sep-06 6:56 
QuestionRe: win32 API - How to use a button Pin
gunner_uk200021-Sep-06 23:23
gunner_uk200021-Sep-06 23:23 
AnswerRe: win32 API - How to use a button [modified] Pin
David Crow22-Sep-06 3:01
David Crow22-Sep-06 3:01 
AnswerRe: win32 API - How to use a button Pin
susiriss22-Sep-06 3:25
susiriss22-Sep-06 3:25 
QuestionShell open with Pin
Mohammad A Gdeisat21-Sep-06 6:13
Mohammad A Gdeisat21-Sep-06 6:13 
Questionarray input using edit box Pin
Cyclone0221-Sep-06 5:27
Cyclone0221-Sep-06 5:27 
AnswerRe: array input using edit box Pin
Zac Howland21-Sep-06 5:39
Zac Howland21-Sep-06 5:39 
AnswerRe: array input using edit box Pin
David Crow21-Sep-06 6:59
David Crow21-Sep-06 6:59 
GeneralRe: array input using edit box Pin
Cyclone0221-Sep-06 7:15
Cyclone0221-Sep-06 7:15 
GeneralRe: array input using edit box Pin
David Crow21-Sep-06 7:28
David Crow21-Sep-06 7:28 
GeneralRe: array input using edit box Pin
Cyclone0222-Sep-06 5:59
Cyclone0222-Sep-06 5:59 
QuestionCall Windows Explorer after save files Pin
Max++21-Sep-06 5:19
Max++21-Sep-06 5:19 
AnswerRe: Call Windows Explorer after save files Pin
toxcct21-Sep-06 5:39
toxcct21-Sep-06 5:39 
QuestionDialog don't get focus back [modified] Pin
jsumm21-Sep-06 4:34
jsumm21-Sep-06 4:34 
QuestionComparing enum types Pin
Waldermort21-Sep-06 4:25
Waldermort21-Sep-06 4:25 
AnswerRe: Comparing enum types Pin
Zac Howland21-Sep-06 4:44
Zac Howland21-Sep-06 4:44 
GeneralRe: Comparing enum types Pin
Waldermort21-Sep-06 5:21
Waldermort21-Sep-06 5:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.