|
From: Site R. <sit...@fl...> - 2004-03-25 02:51:30
|
Sorry for posting again. This is really stumping me. I tried adding a =
resource file to my project. In one of my projects it works perfectly =
fine, but it doesn't seem to want to do so now. I selected new source =
file, it asked me if I was sure I wanted to add a new one to the =
project, I selected yes, and saved the files as editor.h and editor.rc. =
then of course I had my main.cpp. It worked fine until I added the =
dialog in my .rc file.
My project is not too large, so I will add all the code right here, in =
case that is the reason why. or maybe I am doing something wrong?
//// editor.rc
#include "editor.h"
IDR_MAINMENU MENU
{
POPUP "&File"
{
MENUITEM "&New", IDM_FILE_NEW
}
}
IDR_SENTENCES DIALOG 0, 0, 200, 200
STYLE WS_POPUP|WS_CAPTION|WS_SYSMENU
CAPTION "Sentences"
{
EDITTEXT IDD_EDIT, 2, 2, 197, 178, ES_READONLY
DEFPUSHBUTTON "OK", IDOK, 80, 182, 25, 14
}
/// editor.h
#ifndef __EDITOR_H
#define __EDITOR_H
#define IDR_MAINMENU 110
#define IDM_FILE_NEW 111
#define IDR_SENTENCES 112
#define IDD_EDIT 113
#endif // __EDITOR_H
// editor.cpp
#include "editor.h"
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
// dialog procedure for the sentences
BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] =3D "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are =
saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance =3D hThisInstance;
wincl.lpszClassName =3D szClassName;
wincl.lpfnWndProc =3D WindowProcedure; /* This function is =
called by windows */
wincl.style =3D CS_DBLCLKS; /* Catch double-clicks =
*/
wincl.cbSize =3D sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon =3D LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm =3D LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor =3D LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName =3D NULL; // MAKEINTRESOURCE(IDR_MAINMENU);
wincl.cbClsExtra =3D 0; /* No extra bytes after =
the window class */
wincl.cbWndExtra =3D 0; /* structure or the =
window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground =3D (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd =3D CreateWindowEx (
0, /* Extended possibilites for variation =
*/
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the =
screen */
640, /* The programs width */
480, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to =
desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() =
gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() =
*/
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM =
wParam, LPARAM lParam)
{
HWND p[8];
HWND sentences;
switch (message) /* handle the messages */
{
case WM_CREATE:
{
DWORD hpos;
int i=3D0;
for (hpos =3D 10; hpos < 590; hpos +=3D 145, i++)
{
p[i] =3D CreateWindow("EDIT", "", WS_VISIBLE|WS_CHILD, hpos, 5, =
100, 50, hwnd, (HMENU)(100 + i), GetModuleHandle(0), NULL);
} // end for
=20
SetWindowText(p[0], "La Casa");
SetWindowText(p[1], "El Restaurante");
SetWindowText(p[2], "El Museo");
SetWindowText(p[3], "El Hotel");
=20
i=3D4;
for (hpos =3D 10; hpos < 590; hpos +=3D 145, i++)
{
p[i] =3D CreateWindow("EDIT", "", WS_VISIBLE|WS_CHILD, hpos, =
150, 100, 50, hwnd, (HMENU)(100 + i), GetModuleHandle(0), NULL);
} // end for
=20
SetWindowText(p[4], "La Tienda");
SetWindowText(p[5], "El Cine");
SetWindowText(p[6], "La Biblioteca");
SetWindowText(p[7], "El Correo");
=20
=20
=20
sentences =3D CreateWindow("BUTTON", "Sentences", =
WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON, 250, 250, 75, 50, hwnd, =
(HMENU)108, GetModuleHandle(0), NULL);
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case 108:
DialogBox(GetModuleHandle(0), MAKEINTRESOURCE(IDR_SENTENCES), hwnd, =
DlgProc);
break;
}
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message =
queue */
break;
default: /* for messages that we don't deal =
with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
SetDlgItemText(hwnd, IDD_EDIT, "hi");
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCANCEL:
EndDialog(hwnd, IDCANCEL);
break;
} // end switch
break;
default:
return FALSE;
} // end switch
return TRUE;
}
// end of project
I know the name doesn't quite fit the purpose! but oh well. I am just =
very stumped about this, why it is doing this. There error I get is =
something like the following:
"C:\Dev-Cpp\projects\editor\makefile.... [build error] =
[editor_private.res] error 1"
thanks for any help, again.
Brandon |