Click here to Skip to main content
15,912,021 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help with derived class Pin
John M. Drescher16-Apr-05 5:32
John M. Drescher16-Apr-05 5:32 
GeneralRe: Help with derived class Pin
David Crow18-Apr-05 4:26
David Crow18-Apr-05 4:26 
GeneralRe: Help with derived class Pin
Blake Miller18-Apr-05 8:29
Blake Miller18-Apr-05 8:29 
GeneralRe: Help with derived class Pin
David Crow18-Apr-05 9:32
David Crow18-Apr-05 9:32 
GeneralRe: Help with derived class Pin
Blake Miller18-Apr-05 9:54
Blake Miller18-Apr-05 9:54 
GeneralRe: Help with derived class Pin
David Crow18-Apr-05 10:06
David Crow18-Apr-05 10:06 
GeneralButton Create Pin
Francis Chau16-Apr-05 4:06
Francis Chau16-Apr-05 4:06 
GeneralRe: Button Create Pin
PJ Arends16-Apr-05 6:37
professionalPJ Arends16-Apr-05 6:37 
Francis Chau wrote:
RunButton ( HWND hwnd )
{
CreateWindow(
"BUTTON",
"Run",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // styles
380,
40,
60,
25,
hwnd,
NULL,


This last NULL should be the ID of your button. This will be the value passed in the loword of the wparam parameter in the BN_CLICKED notification.

Francis Chau wrote:
case WM_COMMAND:
switch HIWORD(wParam)
{
case BN_CLICKED:
switch (lParam)
{
case RunButton:


The lParam parameter contains the HWND of your button, which is the return value of the CreateWindow() function. Also the case expression has to be a constant value, the compiler has to know what the value is when it compiles the code, it can not be a value that is generated when the code is run. If you want to switch on a variable then you have to use the if...else if construct.

This is how I would do it, but I would also add some error checking to make sure that CreateWindow() actually was able to create the button.
#define ID_RUNBUTTON 1001
.
.
.
RunButton ( HWND hwnd )
{
   CreateWindow(
   "BUTTON", 
   "Run", 
   WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // styles
   380,
   40, 
   60, 
   25, 
   hwnd,
   ID_RUNBUTTON,
   (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),
   NULL); 
   return 1;
}
.
.
.
case WM_COMMAND:
switch HIWORD(wParam) 
{
   case BN_CLICKED:
   switch (LOWORD(wParam)) 
   {
   case ID_RUNBUTTON:
      CetCapConnect( hwnd ); 
      break; 
   }
break;






"You're obviously a superstar." - Christian Graus about me - 12 Feb '03

"Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04

Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004

GeneralRe: Button Create Pin
Francis Chau16-Apr-05 18:15
Francis Chau16-Apr-05 18:15 
Questionhow to recognize "real" printer in EnumPrinters? Pin
sstoyan16-Apr-05 3:52
sstoyan16-Apr-05 3:52 
AnswerRe: how to recognize "real" printer in EnumPrinters? Pin
Alexander M.,16-Apr-05 11:20
Alexander M.,16-Apr-05 11:20 
GeneralRe: how to recognize "real" printer in EnumPrinters? Pin
sstoyan17-Apr-05 4:43
sstoyan17-Apr-05 4:43 
Generalencryption symetric Pin
3loka16-Apr-05 2:15
3loka16-Apr-05 2:15 
GeneralRe: encryption symetric Pin
22491716-Apr-05 2:21
22491716-Apr-05 2:21 
GeneralRe: encryption symetric Pin
Alexander M.,16-Apr-05 2:32
Alexander M.,16-Apr-05 2:32 
GeneralRe: encryption symetric Pin
22491716-Apr-05 2:55
22491716-Apr-05 2:55 
GeneralRe: encryption symetric Pin
Alexander M.,16-Apr-05 9:49
Alexander M.,16-Apr-05 9:49 
GeneralRe: encryption symetric Pin
3loka24-Apr-05 17:44
3loka24-Apr-05 17:44 
GeneralRe: encryption symetric Pin
Francesco Aruta17-Apr-05 23:57
Francesco Aruta17-Apr-05 23:57 
GeneralRe: encryption symetric Pin
3loka19-Apr-05 20:03
3loka19-Apr-05 20:03 
GeneralRe: encryption symetric Pin
Francesco Aruta20-Apr-05 9:54
Francesco Aruta20-Apr-05 9:54 
GeneralRe: encryption symetric Pin
3loka23-Apr-05 12:48
3loka23-Apr-05 12:48 
GeneralRe: encryption symetric Pin
3loka24-Apr-05 17:42
3loka24-Apr-05 17:42 
GeneralRe: encryption symetric Pin
3loka26-Apr-05 8:52
3loka26-Apr-05 8:52 
GeneralTrying to wake up !! Pin
Still learning how to code16-Apr-05 2:09
Still learning how to code16-Apr-05 2:09 

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.