www.digitalmars.com         C & C++   DMDScript  

c++ - newbie needs help with .rc files

reply stewilled <stewilled_member pathlink.com> writes:
Sorry if this is a stupid question but,

How do i use/include .rc files with my source file with dmc++ in plain english.

thanx so much. 
Mar 07 2006
parent reply Bertel Brander <bertel post4.tele.dk> writes:
stewilled wrote:

 How do i use/include .rc files with my source file with dmc++ in plain english.
A quick example: First create a .rc file: #include <windows.h> #include "dmcdlg.h" IDD_MAINDIALOG DIALOG 100, 100, 200, 80 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "dmcdlg" BEGIN DEFPUSHBUTTON "OK", IDOK, 150, 5, 40, 14 PUSHBUTTON "Add", IDC_ADD_BUTTON, 150, 25, 40, 14 EDITTEXT IDC_EDIT_1, 5, 5, 100, 12, ES_AUTOHSCROLL EDITTEXT IDC_EDIT_2, 5, 22, 100, 12, ES_AUTOHSCROLL LTEXT "Result", IDC_STATIC_1, 5, 39, 100, 12 END And a headerfile: #define IDD_MAINDIALOG 100 #define IDC_ADD_BUTTON 1001 #define IDC_EDIT_1 1002 #define IDC_EDIT_2 1003 #define IDC_STATIC_1 1004 Then a .c file: #include <windows.h> #include "dmcdlg.h" #include <stdio.h> #include <string.h> BOOL CALLBACK DialogFunc(HWND aDlg, UINT aMsg, WPARAM wParam, LPARAM lParam) { switch(aMsg) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: EndDialog(aDlg, 1); return 1; case IDC_ADD_BUTTON: { int N1 = GetDlgItemInt(aDlg, IDC_EDIT_1, 0, TRUE); int N2 = GetDlgItemInt(aDlg, IDC_EDIT_2, 0, TRUE); char Text[128]; sprintf(Text, "%d + %d = %d", N1, N2, N1 + N2); SetDlgItemText(aDlg, IDC_STATIC_1, Text); } break; } break; case WM_CLOSE: EndDialog(aDlg, 0); return TRUE; } return FALSE; } int APIENTRY WinMain(HINSTANCE aHinst, HINSTANCE aHinstPrev, LPSTR aCmdLine, int aCmdShow) { WNDCLASS wc; memset(&wc, 0, sizeof(wc)); wc.lpfnWndProc = DefDlgProc; wc.cbWndExtra = DLGWINDOWEXTRA; wc.hInstance = aHinst; wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hbrBackground = (HBRUSH )(COLOR_WINDOW + 1); wc.lpszClassName = "dmcdlg"; RegisterClass(&wc); return DialogBox(aHinst, MAKEINTRESOURCE(IDD_MAINDIALOG), 0, (DLGPROC )DialogFunc); } Then you can build it all with these commands: dmc -c dmcdlg.c rcc.exe -D__NT__ dmcdlg.rc dmc -L/exet:nt/su:windows dmcdlg.obj dmcdlg.res -- Absolutely not the best homepage on the net: http://home20.inet.tele.dk/midgaard But it's mine - Bertel
Mar 13 2006
parent Bertel Brander <bertel post4.tele.dk> writes:
Bertel Brander wrote:
 
 Then you can build it all with these commands:
 dmc -c dmcdlg.c
 rcc.exe -D__NT__ dmcdlg.rc
 dmc -L/exet:nt/su:windows dmcdlg.obj dmcdlg.res
Forgot to tell; for this to work you have to name your files dmcdlg.rc, dmcdlg.h and dmcdlg.c -- Absolutely not the best homepage on the net: http://home20.inet.tele.dk/midgaard But it's mine - Bertel
Mar 13 2006