Newer versions of VS can run happily without *.user file. If it's missing it will be recreated with some reasonable defaults. So in your case if you go to LAPC you do a git pull and than, the first time, you will have to adjust the .user file to your liking. After that it will stay on that machine.
I am trying to compile a project who use message crackers and is different from those wich I am used with(those projects that uses WindProc procedure and the other functions automatically created by the VS IDE)
This is the windows main function where I call DialogBox function:
int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE hinstPrev, LPSTR pszCmdLine, int nCmdShow)
DialogBox(hinstExe, MAKEINTRESOURCE(IDD_DIRWALK), NULL, Dlg_Proc);
If I place a breakpoint on the Dlg_Proc preocedure, the program never goes there to start it:
I think you are missing the DS_MODALFRAME style from your dialog template. And your message handlers could contain anything - we cannot see the code. As I already suggested to you, get rid of these big defines and put the source in your handler. You will then at least have a chance of finding out what is wrong, as will we. And a better place to learn how to code for Dialogs is at About Dialog Boxes - Win32 apps | Microsoft Docs[^.
Thank you for your response, unfortunately not DS_MODALEFRAME is the problem
The problem is ( I think ), that when DialogBox function is called in WinMain, its associated procedure function Dlg_ProcDlg_Proc isn't executed.
Richard MacCutchan wrote:
And your message handlers could contain anything - we cannot see the code.
Are you reffering to Dlg_OnInitDialog as message handlers? It's code is:
BOOL Dlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
// Associate an icon with the dialog box.
chSETDLGICONS(hwnd, IDI_DIRWALK, IDI_DIRWALK);
// here is some code that I didn't got to, or have patience to write
SetWindowPos(GetDlgItem(hwnd, IDC_TREE), NULL, 0, 0, rc.right, rc.bottom, SWP_NOZORDER);
And the macro for chSETDLGICONS(hwnd, IDI_DIRWALK, IDI_DIRWALK); is:
#define chINITSTRUCT(structure, fInitSize) \
(ZeroMemory(&(structure), sizeof(structure)), \
fInitSize ? (*(int*) &(structure) = sizeof(structure)) : 0)
// Dialog Box Icon Setting Macro// The call to SetClassLong is for Windows NT 3.51 or less.// The WM_SETICON messages are for Windows NT 4.0 and Win 95#define chSETDLGICONS(hwnd, idiLarge, idiSmall) \
OSVERSIONINFO VerInfo; \
chINITSTRUCT(VerInfo, TRUE); \
if ((VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && \
(VerInfo.dwMajorVersion <=3 && \
VerInfo.dwMinorVersion <= 51)) \
SetClassLong(hwnd, GCL_HICON, (LONG) \
SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM) \
SendMessage(hwnd, WM_SETICON, FALSE, (LPARAM) \
But the program dosen't reach the Dlg_OnInitDialog, I placed a breakpoint there.
What do I miss? If it is really necessary for the clearness of the code I wll add and the macros in code.
And guys please don't get upset on me because I insist to solve this old kind of program, but I am curious about this different style of managing windows messages and please help me to go through.
So you have a macro inside a macro which just makes it worse. I suggest you throw this code (and that book) away and write a proper inline handler. I have just tested your template and it loads the dialog and handles the WM_INITDIALOG message:
INT_PTR CALLBACK DlgProc(
return OnInitDialog(hDlg, (HWND)wParam, lParam); // calls the initialization function
return OnCommand(hDlg, LOWORD(wParam), (HWND)lParam, HIWORD(wParam)); // handles any button etc. messages
returnfalse; // default processing
In my opinion I can change the content of the Dlg_Proc for infinite because I don't know why, the program just don't
get to that Function Procedure.
And I don't know why you are ignoring me when I am telling you that my DialogBox function from WinMain doesn't starts
the Dlg_Proc procedure never. Please explain me that because I don't understand. All I want to do for now is to see
that my program stops at a breakpoint on the Dlg_Proc.
Are VC project settings? This is all the code that I have. I am missing something? Just please explain me why the DialogBox
doesn't starts its procedure.
I know to implplement dialog boxes, I have implemented a few, the problem in this topic is that I can't aproach this kind of message handling procedure. And I am sorry if I repeat myself and you try to explain me and I am not able to understand but... "Why the DialogBox from WinMain doesn't start the Dlg_Proc afferent procedure?"
The DialogBox does start, but because your code is invalid it terminates (almost) immediately. I have changed your DialogProc to the following just to make it work:
The DialogBox does start, but it's procedure Dlg_Proc doesn't start, you can modify this procedeure over and over for
one thousand times, is not the problem there. How invalid the code will be, if I put a break point inside of Dlg_Proc
should stop there, but the program never goes there.
Please listen to me, help me to understand why the MessageBox doesn't start DlgProc procedeure. Maybe are project setings or I don't know. The problem is that the Dlg_Proc is never reched and never executed.
Please take my code where I copied all my file apart .cpp .rc the resource file to see that I am right.
Something is missing to me, I don't know why. Maybe somwthing more is need it but please listen on what I am saying,
the problem is that the MessageBox function doesn't start the Dlg_Proc
I told you how to fix it, copy the code from my previous message into your DialogProc. I know that works because I have tested it.
If it still does not work for you then there is something else that you are not showing us.
// Microsoft Visual C++ generated resource script.
// Generated from the TEXTINCLUDE 2 resource.
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1#ifdef APSTUDIO_INVOKED
// Icon with the lowest ID value placed first to ensure
// application icon remains consistent on all systems.
IDI_DIRWALK ICON DISCARDABLE "DirWalk.Ico"// Dialog
IDD_DIRWALK DIALOG DISCARDABLE 10, 18, 250, 250
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP|
WS_VISIBLE| WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | DS_MODALFRAME
CAPTION "Directory Walk"
FONT 8, "System"
LISTBOX IDC_TREE,0,0,0,0,NOT LBS_NOTIFY |
LBX_NOINTEGRAL_HEIGHT | NOT WS_BORDER |
WS_VSCROLL | WS_HSCROLL | WS_GROUP |
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources
// Generated from the TEXTINCLUDE 3 resource.
#endif // not APSTUDIO_INVOKED
// Microsoft Visual C++ generated include file.
// Used by DirWalk.rc
#define IDI_DIRWALK 400
#define IDC_TREE 401
#define IDD_DIRWALK 402
// Next default values for new objects
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
I repeat, I had created a new win32 VC++ empty project and added just these 3 files.
I have to make more settings in VC++ project? Are missing some .h header files that I have to add?
( While posting these, I observed your response Richard about the compiler resource object, thank you very much
for your time trying to help me, I will continue making a hybrid application with my knowledge to continue, in meantime I hope I will find and my need it explanations about this situation, because all I want is to know the basics and then
to start with tones of wrappers and lybraries and so on )
One thing I did notice in your Dialog resource definition was the use of the style value LBX_NOINTEGRAL_HEIGHT. I cannot find a definition of that value anywhere in the Windows header file; I suspect it should be LBS_NOINTEGRAL_HEIGHT.
I don't have time to look at the rest of the above code today, but may be able to get to it tomorrow or next week.
I just built your program from the code in your previous message. I had to add a couple of minor things in the .rc file because of changes in the Win32 libraries. After building the code it runs successfully; i.e. it shows the main dialog with an empty ListView.
Can you please tell me where these adjustments were? So I can take a look at me? Teach me how to fix that problems, where to look. Because it can be from the dialog resource to not load properly the DialogBox and not to go to the Dialog procedure from that reason.
Where can be the problem on me? ( I am using VS 2010 and I did't had problems with it until now).
When I am creating a new empty project, when I choose to add a new .rc file, in this .rc file it's added automatically some code in that file, I was glad to see that, BUT!!! , it's appears that somewhere here was some problems or I wasn't pay attention on something, now I have copied exactly the content of the .rc file provided with the book, and now when I run the project, it's appearing an empty dialog box, it is emty, without the ListWiew, but it's a great start.
I will put tomorrow the content of the file from the book because I am very tired now, and for shure we will see the
critical diferences and for shure I will learn from that.
Whoa, I am so glad, we will find and figure out what the clue is, thank you Richard for your patience.
Last Visit: 31-Dec-99 19:00 Last Update: 26-Nov-22 6:46