Click to See Complete Forum and Search --> : Dialog trouble


zariostr
January 10th, 2004, 07:25 AM
hello
i make own class with Dialog procedure in it as member
so at my code dialog is appear and all. No one controls not work
i have there ok button and cancel button, but i can't click on it
what's problem ???


code is below

#include <windows.h>
#include "resource.h"
#include "BaudDialog.h"

BaudDialog::BaudDialog(HINSTANCE hInstance,HWND hwnd)
{
DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_BAUDDIALOG),hwnd,(DLGPROC)InitBaudProc,(LPARAM)this);
}

BOOL CALLBACK BaudDialog::InitBaudProc(HWND hDlg,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
static BaudDialog* bd;
switch(iMsg)
{
case WM_INITDIALOG:
bd=(BaudDialog*)lParam;
ShowWindow(hDlg,SW_SHOW);
SetFocus(hDlg);
return(TRUE);
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
EndDialog(hDlg,0);
return(TRUE);
case IDCANCEL:
EndDialog(hDlg,0);
return(TRUE);
}
}
return(FALSE);
}

wey97
January 11th, 2004, 10:05 AM
You don't have a WinMain. duh!

Try to understand how simple Windows GUI programs work before you try to do foolish things such as writing your own Dialog class. ;)

Sam Hobbs
January 11th, 2004, 12:16 PM
Originally posted by wey97
You don't have a WinMain. duh!

Try to understand how simple Windows GUI programs work before you try to do foolish things such as writing your own Dialog class. ;) Then it would not execute! Duh!

Try to not foolishly jump to conclusions that are not justified by obvious clues. The question asks about a problem occuring during execution, and that means there is a WinMain.

It is not foolish to write a dialog class; for example, MFC's CDialog class is not foolish.

Sam Hobbs
January 11th, 2004, 12:31 PM
zariostr, there is nothing wrong with the code you show; however, since it is not a complete program, it probably does not show the problem; that is, the part of your program that is the problem. Try showing a more complete sample; for example, the following is a complete sample, excluding the .rc file. This program works.#define STRICT
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "resource.h"

class BaudDialog {
public:
BaudDialog(HINSTANCE, HWND);
static BOOL CALLBACK InitBaudProc(HWND, UINT, WPARAM, LPARAM);
};

int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
BaudDialog Dlg(hInstance, NULL);
return 0;
}

BaudDialog::BaudDialog(HINSTANCE hInstance, HWND hwnd) {
DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_BAUDDIALOG), hwnd,
(DLGPROC)InitBaudProc, (LPARAM)this);
}

BOOL CALLBACK BaudDialog::InitBaudProc(HWND hDlg,UINT iMsg,WPARAM wParam,LPARAM lParam) {
static BaudDialog* bd;
switch(iMsg) {
case WM_INITDIALOG:
bd=(BaudDialog*)lParam;
ShowWindow(hDlg,SW_SHOW);
SetFocus(hDlg);
return(TRUE);
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hDlg,0);
return(TRUE);
case IDCANCEL:
EndDialog(hDlg,0);
return(TRUE);
}
}
return(FALSE);
}

wey97
January 11th, 2004, 03:03 PM
Easy there, tiger.

When someone posts incomplete, unformatted source code they should expect to get incomplete/confusing answers. ;)

And for the record, the wink means a joke ;) i.e. kidding, a light hearted comment not to be taken seriously.

I would think an Elite Member of your supreme stature would have learned to ignore simpleton Junior Members like myself. :rolleyes:

I know it's not foolish to write a dialog class! I've done it!

And it's arguable whether or not the MFC CDialog class is foolish. ;)

Lighten up, dude.

Sam Hobbs
January 11th, 2004, 04:44 PM
Originally posted by wey97
I would think an Elite Member of your supreme stature would have learned to ignore simpleton Junior Members like myself. :rolleyes:Note that zariostr is newer than you are and I was somewhat defending zariostr.

wey97
January 11th, 2004, 05:01 PM
Well we could go on and on all day flaming each other...

I'll admit I was stupid to jump the gun and not really read the question if you'll admit you're extremely pissed off for some reason. :p

Why do you declare a BaudDialog pointer in the Dialog message handler if it's not really being used? Just to have for later use?