macro function definition
-
Hi, I am trying implementing this function:
BOOL Dlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
RECT rect;// Associate an icon with the dialog box. chSETDLGICONS(hwnd, IDI\_DIRWALK, IDI\_DIRWALK); return(TRUE);
}
But the compiler give me this error: error C2065: 'strucure' : undeclared identifier, suggesting me that the error is at the chSETDLGICONS. The chSETDLGICONS is defined as a macro in a .h file:
#define chINITSTRUCT(structure, fInitSize) \
(ZeroMemory(&(strucure), sizeof(structure)), \
fInitSize ? (*(int*) &(structure) = sizeof(structure)) : 0)// Dialog Box Icon Setting Macro
#define chSETDLGICONS(hwnd, idiLarge, idiSmall) \
{ \
OSVERSIONINFO VerInfo; \
chINITSTRUCT(VerInfo, TRUE); \
GetVersionEx(&VerInfo); \
if ((VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && \
(VerInfo.dwMajorVersion <=3 && \
VerInfo.dwMinorVersion <= 51)) \
{ \
SetClassLong(hwnd, GCL_HICON, (LONG) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiLarge))); \
} \
else \
{ \
SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM) \
LoadIcon(GetWindowInstance(hWnd), \
MAKEINTRESOURCE(idilarge))); \
SendMessage(hWnd, WM_SECTION, FALSE, (LPARAM) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiSmall))); \
} \
}From what I am seeing, structure is an identifier used in chINITSTRUCT function that is used in chSETDLGICONS, and I don't know how to repair that error. Please help me with this. Thank you in advance.
-
Hi, I am trying implementing this function:
BOOL Dlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
RECT rect;// Associate an icon with the dialog box. chSETDLGICONS(hwnd, IDI\_DIRWALK, IDI\_DIRWALK); return(TRUE);
}
But the compiler give me this error: error C2065: 'strucure' : undeclared identifier, suggesting me that the error is at the chSETDLGICONS. The chSETDLGICONS is defined as a macro in a .h file:
#define chINITSTRUCT(structure, fInitSize) \
(ZeroMemory(&(strucure), sizeof(structure)), \
fInitSize ? (*(int*) &(structure) = sizeof(structure)) : 0)// Dialog Box Icon Setting Macro
#define chSETDLGICONS(hwnd, idiLarge, idiSmall) \
{ \
OSVERSIONINFO VerInfo; \
chINITSTRUCT(VerInfo, TRUE); \
GetVersionEx(&VerInfo); \
if ((VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && \
(VerInfo.dwMajorVersion <=3 && \
VerInfo.dwMinorVersion <= 51)) \
{ \
SetClassLong(hwnd, GCL_HICON, (LONG) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiLarge))); \
} \
else \
{ \
SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM) \
LoadIcon(GetWindowInstance(hWnd), \
MAKEINTRESOURCE(idilarge))); \
SendMessage(hWnd, WM_SECTION, FALSE, (LPARAM) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiSmall))); \
} \
}From what I am seeing, structure is an identifier used in chINITSTRUCT function that is used in chSETDLGICONS, and I don't know how to repair that error. Please help me with this. Thank you in advance.
Found it, found it,
coco243 wrote:
#define chINITSTRUCT(structure, fInitSize) \ (ZeroMemory(&(strucure), sizeof(structure)), \ fInitSize ? (*(int*) &(structure) = sizeof(structure)) : 0)
I have eaten an "t" letter on second row. But I have another errors, I will repost after I look over. Thak you.
-
Hi, I am trying implementing this function:
BOOL Dlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
RECT rect;// Associate an icon with the dialog box. chSETDLGICONS(hwnd, IDI\_DIRWALK, IDI\_DIRWALK); return(TRUE);
}
But the compiler give me this error: error C2065: 'strucure' : undeclared identifier, suggesting me that the error is at the chSETDLGICONS. The chSETDLGICONS is defined as a macro in a .h file:
#define chINITSTRUCT(structure, fInitSize) \
(ZeroMemory(&(strucure), sizeof(structure)), \
fInitSize ? (*(int*) &(structure) = sizeof(structure)) : 0)// Dialog Box Icon Setting Macro
#define chSETDLGICONS(hwnd, idiLarge, idiSmall) \
{ \
OSVERSIONINFO VerInfo; \
chINITSTRUCT(VerInfo, TRUE); \
GetVersionEx(&VerInfo); \
if ((VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && \
(VerInfo.dwMajorVersion <=3 && \
VerInfo.dwMinorVersion <= 51)) \
{ \
SetClassLong(hwnd, GCL_HICON, (LONG) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiLarge))); \
} \
else \
{ \
SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM) \
LoadIcon(GetWindowInstance(hWnd), \
MAKEINTRESOURCE(idilarge))); \
SendMessage(hWnd, WM_SECTION, FALSE, (LPARAM) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiSmall))); \
} \
}From what I am seeing, structure is an identifier used in chINITSTRUCT function that is used in chSETDLGICONS, and I don't know how to repair that error. Please help me with this. Thank you in advance.
Small typo:
strucure
instead ofstructure
in first argument toZeroMemeory
Mircea
-
Small typo:
strucure
instead ofstructure
in first argument toZeroMemeory
Mircea
-
Found it, found it,
coco243 wrote:
#define chINITSTRUCT(structure, fInitSize) \ (ZeroMemory(&(strucure), sizeof(structure)), \ fInitSize ? (*(int*) &(structure) = sizeof(structure)) : 0)
I have eaten an "t" letter on second row. But I have another errors, I will repost after I look over. Thak you.
Are you seriously targeting Windows versions prior to 3.5 ? :laugh: All the fluff
chSETDLGICONS
goes through is completely useless. My advice would be to replace it with the last 2 SendMessage calls:SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM) \
LoadIcon(GetWindowInstance(hWnd), \
MAKEINTRESOURCE(idilarge))); \
SendMessage(hWnd, WM_SECTION, FALSE, (LPARAM) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiSmall)));Mircea
-
Hi, I am trying implementing this function:
BOOL Dlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
RECT rect;// Associate an icon with the dialog box. chSETDLGICONS(hwnd, IDI\_DIRWALK, IDI\_DIRWALK); return(TRUE);
}
But the compiler give me this error: error C2065: 'strucure' : undeclared identifier, suggesting me that the error is at the chSETDLGICONS. The chSETDLGICONS is defined as a macro in a .h file:
#define chINITSTRUCT(structure, fInitSize) \
(ZeroMemory(&(strucure), sizeof(structure)), \
fInitSize ? (*(int*) &(structure) = sizeof(structure)) : 0)// Dialog Box Icon Setting Macro
#define chSETDLGICONS(hwnd, idiLarge, idiSmall) \
{ \
OSVERSIONINFO VerInfo; \
chINITSTRUCT(VerInfo, TRUE); \
GetVersionEx(&VerInfo); \
if ((VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && \
(VerInfo.dwMajorVersion <=3 && \
VerInfo.dwMinorVersion <= 51)) \
{ \
SetClassLong(hwnd, GCL_HICON, (LONG) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiLarge))); \
} \
else \
{ \
SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM) \
LoadIcon(GetWindowInstance(hWnd), \
MAKEINTRESOURCE(idilarge))); \
SendMessage(hWnd, WM_SECTION, FALSE, (LPARAM) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiSmall))); \
} \
}From what I am seeing, structure is an identifier used in chINITSTRUCT function that is used in chSETDLGICONS, and I don't know how to repair that error. Please help me with this. Thank you in advance.
-
I have and this error to, that I don't know how to solve it:
Quote:
error C3861: 'GetWindowInstance': identifier not found
I don't know at where to take this function. If you cand help me and with this to. Thank you,
-
Are you seriously targeting Windows versions prior to 3.5 ? :laugh: All the fluff
chSETDLGICONS
goes through is completely useless. My advice would be to replace it with the last 2 SendMessage calls:SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM) \
LoadIcon(GetWindowInstance(hWnd), \
MAKEINTRESOURCE(idilarge))); \
SendMessage(hWnd, WM_SECTION, FALSE, (LPARAM) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiSmall)));Mircea
Don't laugh about me :laugh: I am learning WINAPI from an old book :laugh: . ( I have understand it that is no sense to check if windows is less than 3.5 ) Until now, I had to compile code that was written with WindProc procedure, but the author has now been found to shoot me in the knee with message crackers ( now I am google it for them to understand them ). I hope to go with this code until the finish, because I have to handle and with those macro funcions now. Aniway I am confident because I have your help.
-
Don't laugh about me :laugh: I am learning WINAPI from an old book :laugh: . ( I have understand it that is no sense to check if windows is less than 3.5 ) Until now, I had to compile code that was written with WindProc procedure, but the author has now been found to shoot me in the knee with message crackers ( now I am google it for them to understand them ). I hope to go with this code until the finish, because I have to handle and with those macro funcions now. Aniway I am confident because I have your help.
Honestly, I don't think it's that useful to learn Win32 API. World has moved over to other technologies in the last 20-25 years. Whatever books you find, they are old (not much money to be made by authors writing about a dead subject) and the skills you acquire they are not in high demand.
Mircea
-
Honestly, I don't think it's that useful to learn Win32 API. World has moved over to other technologies in the last 20-25 years. Whatever books you find, they are old (not much money to be made by authors writing about a dead subject) and the skills you acquire they are not in high demand.
Mircea
I am feeling too that I am not quite on the right path. I wanted to enter in the world of programming and I started to learn C++. Then I said that C++ is a tool, and I realized that I have to do something with this tool and I have start to learn WINAPI beacause I wanted to be capable to design some interfaces from scrap. This was the path that I choose to walk through and I keept going, good or bad that was what I knew to do. Now I am at the finish of this WINAPI book and I am planning to learn and some data bases. I want to enter in the world of programming and to be able to work on my own, if you have advices for me I am more than glad to count on them. Thank you very much,
-
Hi, I am trying implementing this function:
BOOL Dlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
RECT rect;// Associate an icon with the dialog box. chSETDLGICONS(hwnd, IDI\_DIRWALK, IDI\_DIRWALK); return(TRUE);
}
But the compiler give me this error: error C2065: 'strucure' : undeclared identifier, suggesting me that the error is at the chSETDLGICONS. The chSETDLGICONS is defined as a macro in a .h file:
#define chINITSTRUCT(structure, fInitSize) \
(ZeroMemory(&(strucure), sizeof(structure)), \
fInitSize ? (*(int*) &(structure) = sizeof(structure)) : 0)// Dialog Box Icon Setting Macro
#define chSETDLGICONS(hwnd, idiLarge, idiSmall) \
{ \
OSVERSIONINFO VerInfo; \
chINITSTRUCT(VerInfo, TRUE); \
GetVersionEx(&VerInfo); \
if ((VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && \
(VerInfo.dwMajorVersion <=3 && \
VerInfo.dwMinorVersion <= 51)) \
{ \
SetClassLong(hwnd, GCL_HICON, (LONG) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiLarge))); \
} \
else \
{ \
SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM) \
LoadIcon(GetWindowInstance(hWnd), \
MAKEINTRESOURCE(idilarge))); \
SendMessage(hWnd, WM_SECTION, FALSE, (LPARAM) \
LoadIcon(GetWindowInstance(hwnd), \
MAKEINTRESOURCE(idiSmall))); \
} \
}From what I am seeing, structure is an identifier used in chINITSTRUCT function that is used in chSETDLGICONS, and I don't know how to repair that error. Please help me with this. Thank you in advance.
-
Why would you use a macro for something that you only need once? Or even if you need it more than once you should make it a callable function.
-
I am trying to compile some code from a book to understand what the author wants to transmit. Maybe the book it is a bit old and that's why some tehniques are inappropiate.
The problem with using that sort of macro is that they are a pain to debug when something goes wrong. All you need to do is copy and paste the actual lines of code into your
OnInitDialog
function. And remember to remove all those backslashes. You can then easily step through line by line in the debugger if necessary. -
The problem with using that sort of macro is that they are a pain to debug when something goes wrong. All you need to do is copy and paste the actual lines of code into your
OnInitDialog
function. And remember to remove all those backslashes. You can then easily step through line by line in the debugger if necessary.Yes, I had wondered myself if it is any method to see where is the error in this macro functions because compiler says generally that is an error in a macro function but you have to search through all lines of the code to see where the error could be. And those backslash are very wierd, I don't know what is their role.
-
I am feeling too that I am not quite on the right path. I wanted to enter in the world of programming and I started to learn C++. Then I said that C++ is a tool, and I realized that I have to do something with this tool and I have start to learn WINAPI beacause I wanted to be capable to design some interfaces from scrap. This was the path that I choose to walk through and I keept going, good or bad that was what I knew to do. Now I am at the finish of this WINAPI book and I am planning to learn and some data bases. I want to enter in the world of programming and to be able to work on my own, if you have advices for me I am more than glad to count on them. Thank you very much,
coco243 wrote:
if you have advices for me I am more than glad to count on them.
Well, I am sorry to say that you have probably wasted your time learning the Windows API. Especially so if you now want to learn database programming. You really need to move into the .NET field if you expect to make a career in programming. .NET Book Zero by Charles Petzold[^] is an excellent introduction. Beyond that there are plenty of free tutorials online, for advanced C# and database programming. A word of warning: stay clear of youtube tutorials as they tend to be less than good quality.
-
Yes, I had wondered myself if it is any method to see where is the error in this macro functions because compiler says generally that is an error in a macro function but you have to search through all lines of the code to see where the error could be. And those backslash are very wierd, I don't know what is their role.
The backslashes are there to tell the macro processor to include them all until it finds a line that just ends in a newline.
#define FOO(x) \ // means the definition continues onto the next line
x *= 25; \ // still more to come
printf("X = %d\n"); // no backslash so this is the last line to include -
coco243 wrote:
if you have advices for me I am more than glad to count on them.
Well, I am sorry to say that you have probably wasted your time learning the Windows API. Especially so if you now want to learn database programming. You really need to move into the .NET field if you expect to make a career in programming. .NET Book Zero by Charles Petzold[^] is an excellent introduction. Beyond that there are plenty of free tutorials online, for advanced C# and database programming. A word of warning: stay clear of youtube tutorials as they tend to be less than good quality.
Richard MacCutchan wrote:
Well, I am sorry to say that you have probably wasted your time learning the Windows API
I saw in that a possibility to learn making an user interface in my desire to make stand alone applications.
Richard MacCutchan wrote:
Especially so if you now want to learn database programming
I don't necessary want to learn database programming but I consider that when you build applications you would need to use databases at some time.
Richard MacCutchan wrote:
You really need to move into the .NET field if you expect to make a career in programming. .NET Book Zero by Charles Petzold[^] is an excellent introduction.
Thank you for the advice, and for the resource link.
-
Richard MacCutchan wrote:
Well, I am sorry to say that you have probably wasted your time learning the Windows API
I saw in that a possibility to learn making an user interface in my desire to make stand alone applications.
Richard MacCutchan wrote:
Especially so if you now want to learn database programming
I don't necessary want to learn database programming but I consider that when you build applications you would need to use databases at some time.
Richard MacCutchan wrote:
You really need to move into the .NET field if you expect to make a career in programming. .NET Book Zero by Charles Petzold[^] is an excellent introduction.
Thank you for the advice, and for the resource link.
coco243 wrote:
I saw in that a possibility to learn making an user interface in my desire to make stand alone applications.
Which is so much easier to do in .NET as the framework does all the detailed fiddling about, and leaves you to focus on the actual presentation and business logic.
-
coco243 wrote:
I saw in that a possibility to learn making an user interface in my desire to make stand alone applications.
Which is so much easier to do in .NET as the framework does all the detailed fiddling about, and leaves you to focus on the actual presentation and business logic.
Thank you for your thoughts, I will end this WINAPI subject book because I have a few chapters until the end and I have to finish what I have started and I will start reading your sugested documentation about .NET because, honestly I don't have a clear image about what .NET it is and could de but I think that the fact that I had learned something about WINAPI apps will help me to beter understanding. Thank you.
-
Honestly, I don't think it's that useful to learn Win32 API. World has moved over to other technologies in the last 20-25 years. Whatever books you find, they are old (not much money to be made by authors writing about a dead subject) and the skills you acquire they are not in high demand.
Mircea
If you learn something for the intention of making yourself an income, then the Win32 API is not the right choice in the year 2025. On the other hand ... I learned Windows programming before there was a WIN32 API, it was way back in the 16-bit days of the "WIN16 API" (it was never called that). My primary learning was not an API, but event driven programming: Taking your data structures from one consistent state to another consistent state in well defined, atomic steps. Always leaving your data so that it can be properly used by anyone else the next time something happens. No loose ends, no garbage on the floor. Looking upon each event cycle similar to a database transaction. A great philosophy for building robust software. Often, programmers show me code: 'See, I am doing event driven programming too - here is the switch case on the input value!' But even driven is so much more than a switch statement. What I see is a lot of other logic that is not at all related to the state and event, lots of loose ends, lots of garbage variables affecting the state without being treated as state data. The Windows model put a strong pressure on you to do 'clean' event driven coding. Today, working in C#, I still think in event/state terms, taking data structures through well defined, finite processing steps from on consistent state to another. I didn't learn that from any book published this millennium. I didn't learn it from younger coworkers. I didn't learn it from browsing programming forums on the Internet. I learned it from the Windows API. I am really happy to have that background when programming in the year 2022, with the tools of year 2022. Learning the Windows API / event driven programming was certainly no waste of time. It has great value for me, even today.