I am compiling a project with the folowing files and sources on Windows XP.
resource.h
define IDR_MYMENU 101
define IDR_MYICON 102
define IDD_ABOUT 103
define ID_FILE_EXIT 9001
define ID_STUFF_GO 9002
define ID_HELP_ABOUT 9003
--
resource.rc
if !defined (_WINDOWS)
define _WINDOWS
endif
ifndef IDC_STATIC
define IDC_STATIC (-1)
endif
include "windows.h"
include "resource.h"
IDR_MYMENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Stuff"
BEGIN
MENUITEM "&Go", ID_STUFF_GO
MENUITEM "G&o somewhere else", 0, GRAYED
END
POPUP "&Help"
BEGIN
MENUITEM "&About", ID_HELP_ABOUT
END
END
IDI_MYICON ICON "Smile.ico"
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 239, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "My about box....."
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK", IDOK, 174, 18, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 174, 35, 50, 14
GROUPBOX "About this program....", IDC_STATIC, 7, 7, 225, 52
CTEXT "An example program showing how to display Dialog Boxes/r/n/r/nby theForger",
IDC_STATIC, 16, 18, 144, 33
END
--
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 /
/*TheWindowstructure*/wincl.hInstance=hThisInstance;wincl.lpszClassName=szClassName;wincl.lpfnWndProc=WindowProcedure;/*Thisfunctioniscalledbywindows*/wincl.style=CS_DBLCLKS;/*Catchdouble-clicks*/wincl.cbSize=sizeof(WNDCLASSEX);/*Usedefaulticonandmouse-pointer*/wincl.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MYICON));wincl.hIconSm=LoadIcon(NULL,MAKEINTRESOURCE(IDR_MYICON));wincl.hCursor=LoadCursor(NULL,IDC_ARROW);wincl.lpszMenuName=MAKEINTRESOURCE(IDR_MYMENU);/*Nomenu*/wincl.cbClsExtra=0;/*Noextrabytesafterthewindowclass*/wincl.cbWndExtra=0;/*structureorthewindowinstance*//*UseWindows's default color as the background of the window */wincl.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);/*Registerthewindowclass,andifitfailsquittheprogram*/if(!RegisterClassEx(&wincl))return0;/*Theclassisregistered,let's create the program*/hwnd=CreateWindowEx(0,/*Extendedpossibilitesforvariation*/szClassName,/*Classname*/"WindowsApp",/*TitleText*/WS_OVERLAPPEDWINDOW,/*defaultwindow*/CW_USEDEFAULT,/*Windowsdecidestheposition*/CW_USEDEFAULT,/*wherethewindowendsuponthescreen*/544,/*Theprogramswidth*/375,/*andheightinpixels*/HWND_DESKTOP,/*Thewindowisachild-windowtodesktop*/NULL,/*Nomenu*/hThisInstance,/*ProgramInstancehandler*/NULL/*NoWindowCreationdata*/);/*Makethewindowvisibleonthescreen*/ShowWindow(hwnd,nFunsterStil);/*Runthemessageloop.ItwillrununtilGetMessage()returns0*/while(GetMessage(&messages,NULL,0,0)){/*Translatevirtual-keymessagesintocharactermessages*/TranslateMessage(&messages);/*SendmessagetoWindowProcedure*/DispatchMessage(&messages);}/*Theprogramreturn-valueis0-ThevaluethatPostQuitMessage()gave*/returnmessages.wParam;
}
/ This function is called by the Windows function DispatchMessage() /
hIconSm=(HICON)LoadImage(NULL,"Smile.ico",IMAGE_ICON,16,16,LR_LOADFROMFILE);if(hIconSm)SendMessage(hwnd,WM_SETICON,ICON_SMALL,(LPARAM)hIconSm);elseMessageBox(hwnd,"Couldnotloadsmallicon!","Error",MB_OK|MB_ICONERROR);}break;caseWM_COMMAND:switch(LOWORD(wParam)){caseID_FILE_EXIT:PostMessage(hwnd,WM_CLOSE,0,0);break;caseID_STUFF_GO:MessageBox(NULL,"Woooooooooooh,youclickedgo!","Go",MB_ICONEXCLAMATION|MB_OK);break;caseID_HELP_ABOUT:intret=DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_ABOUT),hwnd,AboutDlgProc);if(ret==IDOK){MessageBox(hwnd,"DialogexitedwithIDOK.","Notice",MB_OK|MB_ICONINFORMATION);}elseif(ret==IDCANCEL){MessageBox(hwnd,"DialogexitedwithIDCANCEL.","Notice",MB_OK|MB_ICONINFORMATION);}elseif(ret==-1){MessageBox(hwnd,"Dialogfailed!","Error",MB_OK|MB_ICONINFORMATION);}break;}break;caseWM_DESTROY:PostQuitMessage(0);/*sendaWM_QUITtothemessagequeue*/break;default:/*formessagesthatwedon't deal with */returnDefWindowProc(hwnd,message,wParam,lParam);}return0;
}
Here's the compile log.
Compile Log
Compiler: Default compiler
Building Makefile: "C:\mycppstuff\menu3\Makefile.win"
Executing make clean
rm -f main.o Project1_private.res Project1.exe
rm: Project1.exe: Permission denied
make.exe: *** [clean] Error 1
Execution terminated
My program doesn't show up when I try to run it from Dev-Cpp or from browsing for it and double-clicking on it. The compile buttons on the compiler are ghosted out when I run it, but nothing happens. I have tried a rebuild All and it doesn't work. Could somebody please help me?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
it is telling you that the attempt to "rm" which is the command to remove failed,
because the permission to do the removal operation was not granted by the OS.
This can arise from several things. It comes up with a lot of new folks because they
started a program that had that name, and never really shut it down. The OS will not let
a file that is being executed be deleted. The brute force way to kill a task like this
is a restart, with a less brute force means being to look through the task manager and
kill it from there.
It could also be a permision issue with the folder that the file is in.
A variety of things, subtle things can lead to a given error condition, so you begin
to see how hard it it to remote debug someone's problem when you are not there with
them. I say this because a lot of new folks are under the impression that we can
look at an error message, and come up with an instant diagnosis - if only it were that
easy. :(
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok thanks for the help that you could give. It turns out six instances of my application were being run as processes so they were a little harder to track down. I ended those and now it works. Thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am compiling a project with the folowing files and sources on Windows XP.
resource.h
define IDR_MYMENU 101
define IDR_MYICON 102
define IDD_ABOUT 103
define ID_FILE_EXIT 9001
define ID_STUFF_GO 9002
define ID_HELP_ABOUT 9003
--
resource.rc
if !defined (_WINDOWS)
define _WINDOWS
endif
ifndef IDC_STATIC
define IDC_STATIC (-1)
endif
include "windows.h"
include "resource.h"
IDR_MYMENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Stuff"
BEGIN
MENUITEM "&Go", ID_STUFF_GO
MENUITEM "G&o somewhere else", 0, GRAYED
END
POPUP "&Help"
BEGIN
MENUITEM "&About", ID_HELP_ABOUT
END
END
IDI_MYICON ICON "Smile.ico"
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 239, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "My about box....."
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK", IDOK, 174, 18, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 174, 35, 50, 14
GROUPBOX "About this program....", IDC_STATIC, 7, 7, 225, 52
CTEXT "An example program showing how to display Dialog Boxes/r/n/r/nby theForger",
IDC_STATIC, 16, 18, 144, 33
END
--
Main.cpp
include <windows.h>
include "resource.h"
define ID_FILE_EXIT 9001
define ID_STUFF_GO 9002
HICON hIcon;
HICON hIconSm;
/ Declare Windows procedure /
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/ Make the class name into a global variable /
char szClassName[ ] = "WindowsApp";
BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
}
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 /
}
/ This function is called by the Windows function DispatchMessage() /
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) / handle the messages /
{
case WM_CREATE:
{
HICON hIcon, hIconSm;
hIcon = (HICON)LoadImage(NULL, "Smile.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
if(hIcon)
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
else
MessageBox(hwnd, "Could not load large icon!", "Error", MB_OK | MB_ICONERROR);
}
Here's the compile log.
Compile Log
Compiler: Default compiler
Building Makefile: "C:\mycppstuff\menu3\Makefile.win"
Executing make clean
rm -f main.o Project1_private.res Project1.exe
rm: Project1.exe: Permission denied
make.exe: *** [clean] Error 1
Execution terminated
My program doesn't show up when I try to run it from Dev-Cpp or from browsing for it and double-clicking on it. The compile buttons on the compiler are ghosted out when I run it, but nothing happens. I have tried a rebuild All and it doesn't work. Could somebody please help me?
This error suggest something:
"rm: Project1.exe: Permission denied"
it is telling you that the attempt to "rm" which is the command to remove failed,
because the permission to do the removal operation was not granted by the OS.
This can arise from several things. It comes up with a lot of new folks because they
started a program that had that name, and never really shut it down. The OS will not let
a file that is being executed be deleted. The brute force way to kill a task like this
is a restart, with a less brute force means being to look through the task manager and
kill it from there.
It could also be a permision issue with the folder that the file is in.
A variety of things, subtle things can lead to a given error condition, so you begin
to see how hard it it to remote debug someone's problem when you are not there with
them. I say this because a lot of new folks are under the impression that we can
look at an error message, and come up with an instant diagnosis - if only it were that
easy. :(
Wayne
Ok thanks for the help that you could give. It turns out six instances of my application were being run as processes so they were a little harder to track down. I ended those and now it works. Thanks again.
Great!
Like I said, there is always the brute force means of a restart.
As I am sure Clifford would volunteer, if there is a simple-minded and stupid
solution to a problem, Wayne will suggest it. Big :)
Wayne