I'm using Dev-C++ for several month to develop small utilities, all simple dialog applications.
Until now I did this with simple Win32 API programming without really using the features of C++.
But as the amount of program grows I wanted to do so, without starting over with MS VC++ and MFC.
I tried to do the basics of a simple dialog window in C++, but I got stuck.
Can anyone teach me how to convert the following piece of code for a simple dialog, so that I can use functions as On_Init(), On_Command(), On_Close(), ...,
so that I can create a kind of template for creating new projects.
Resource.h:
define IDD_DLG 100
define ID_BUTTON 4001
Resource.rc:
include <windows.h>
include "Resource.h"
IDD_DLG DIALOG 0, 0, 100, 50
STYLE DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "MyDialog"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "Button", ID_BUTTON, 30, 18, 40, 14
END
You can look in the forum faq useful links section for some tutorials, there should be one called something like foosyerdoos that I think has stuff about classes for Windows, might be a few other useful ones too.
You might also want to look into message crackers and the windowsx.h file which defines a whole bunch of macros for handling messages.
b_a
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm using Dev-C++ for several month to develop small utilities, all simple dialog applications.
Until now I did this with simple Win32 API programming without really using the features of C++.
But as the amount of program grows I wanted to do so, without starting over with MS VC++ and MFC.
I tried to do the basics of a simple dialog window in C++, but I got stuck.
Can anyone teach me how to convert the following piece of code for a simple dialog, so that I can use functions as On_Init(), On_Command(), On_Close(), ...,
so that I can create a kind of template for creating new projects.
Resource.h:
define IDD_DLG 100
define ID_BUTTON 4001
Resource.rc:
include <windows.h>
include "Resource.h"
IDD_DLG DIALOG 0, 0, 100, 50
STYLE DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "MyDialog"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "Button", ID_BUTTON, 30, 18, 40, 14
END
Main.cpp:
include <windows.h>
include "Resource.h"
/ Declare dialog procedure /
BOOL CALLBACK DlgProc (HWND, UINT, WPARAM, LPARAM);
/ Windows main function /
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLG), NULL, DlgProc);
}
/ Implementation of dialog procedure /
BOOL CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) // Handle messages
{
case WM_INITDIALOG: // Dialog is created
break;
}
return TRUE;
}
I think I would not be the only one who is interested in this.
Thank you!!
I'm looking forward to any explanations or hints!
PS:
Excuse my obviosly bad english, hope you understood what I wrote.
http://www.foosyerdoos.fsnet.co.uk/
Derek
You can look in the forum faq useful links section for some tutorials, there should be one called something like foosyerdoos that I think has stuff about classes for Windows, might be a few other useful ones too.
You might also want to look into message crackers and the windowsx.h file which defines a whole bunch of macros for handling messages.
b_a