Mail Archives: cygwin/2007/04/20/11:03:59
Hi,
I believe I have found a bug in windres (appears to be part of the
binutils-20060817-1 package).
If I define POPUP Submenus of a MENUEX, the resulting resource is
corrupt.
I have constructed a small example to show the error:
| karoshi:~/demo>make
| windres -i res.rc -o res.o
| cc -g -O -Wall -mno-cygwin -o demo demo.c res.o
| karoshi:~/demo>./demo.exe
| LoadMenu failed with error 13: Die Daten sind unzulässig.
(sorry for the german error message, it is "The Data is invalid")
I have found an (old) mail with a patch for the very same problem. It
can be viewed at:
http://sources.redhat.com/ml/binutils/2004-06/msg00609.html
Unfortunately I don't know how to recompile parts of cygwin, so I can't
test that patch, but it would be really great if somebody could look at
this.
----------------------------------------------------------------------
Example resource file "res.rc":
#include <windows.h>
123 MENUEX
BEGIN
POPUP "Dummy", 144
BEGIN
MENUITEM "&About...", 1
END
END
----------------------------------------------------------------------
Example c program "demo.c":
#include <stdio.h>
#include <string.h>
#include <windows.h>
void ErrorExit(char *);
int APIENTRY WinMain(HINSTANCE hInst,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow){
HMENU hCtxMenu;
hCtxMenu=LoadMenu (hInst, MAKEINTRESOURCE(123));
if(hCtxMenu==NULL){
ErrorExit("LoadMenu");
};
return 0;
}
void ErrorExit(char *text) {
TCHAR szBuf[80];
LPVOID lpMsgBuf;
DWORD dw = GetLastError();
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
wsprintf(szBuf, "%s failed with error %d: %s", text, dw, lpMsgBuf);
printf("%s",szBuf);
LocalFree(lpMsgBuf);
ExitProcess(dw);
};
----------------------------------------------------------------------
Example Makefile "Makefile":
CFLAGS+=-g -O -Wall -mno-cygwin
LIBS=
PRG=demo
${PRG}: ${PRG}.c res.o
${CC} ${CFLAGS} -o ${PRG} ${PRG}.c res.o ${LIBS}
res.o: res.rc
windres -i $< -o $@
----------------------------------------------------------------------
Thanks,
Sec
P.S.: if you remove the ",144" part from the POPUP statement, the
program will run fine. This is because windres then compiles it as
"MENU" instead of "MENUEX", which can be verified with "windres -i res.o"
--
The most successful method of programming is to begin a program as
simply as possible, test it, and then add to the program until it
performs the required job." -- PDP8 handbook, Pg 9-64
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -