That was what I was assuming. However, assuming that to be correct, adapting Codeplug's example gives:
SetWindowLong(hwnd, GWL_USERDATA, 0x1234abcd); // GWL_USERDATA = -21
SetWindowLong(hwnd,...
Type: Posts; User: DL1
That was what I was assuming. However, assuming that to be correct, adapting Codeplug's example gives:
SetWindowLong(hwnd, GWL_USERDATA, 0x1234abcd); // GWL_USERDATA = -21
SetWindowLong(hwnd,...
I know in practice it's not important to know the numerical values; I'm just really, really curious because it looks so wrong to me.
I am a bit puzzled by the SetWindowLong function, as described here:
SetWindowLong function
Specifically, I cannot make sense of the offsets given for the argument nIndex. For example,...
I had two files with following:
#include <stdio.h>
#include <stdlib.h>
struct point {int x; int y; int z;};
extern struct point p2;
int main()
So you can have two structure declarations (or class definitions) with the same name in different files, with one having additional members? My compiler doesn't complain about this for C or C++; I...
I see. Does this mean the new code will be compiled with a new definition of the structure (containing the additional members), which is different from the definition used for compilation of the old...
Hello,
Why might a struct need a field containing the size of the struct (for example, in Windows programming, the first field of the struct WNDCLASSEX is generally set to sizeof(WNDCLASSEX))? Can...
Yes, the code is pretty old. And it seems that in pre-ANSI C, locally defined character arrays initialized with strings had to be static.
Hello,
I am unsure why szAppName in the following program (and in virtually every other windows application I have seen) is declared static:
#include <windows.h>
LRESULT CALLBACK WndProc...
So if you set WS_VISIBLE you make both the ShowWindow() and UpdateWindow() calls redundant.
adeyblue, I didn't see your reply before posting mine. Anyhow, I would still be very interested to hear exactly what event it is that causes the WM_PAINT to be sent if there is no UpdateWindow()...
So the UpdateWindow() in the example is redundant?
And is it thus the ShowWindow() call that causes the WM_PAINT? If I understand Petzold correctly, he implies that ShowWindow() doesn't cause a...
Hello,
On my machine, running the following causes "Hello, Windows 98!" to be painted immediately, even with the call of UpdateWindow() in WinMain commented out. According to Charles Petzold in...
I am not trying to be obtuse here, but I can't actually see why casting makes the code more obviously correct.
In the normal case, I will be a DWORD (that is surely the whole point of the macro),...
I still don't get it. Even if that happened, and you ended up with 16 1s in front of the number, aren't they going to be discarded when the result is cast to WORD?
It seems to me that all you are...
Hello all,
I am a bit puzzled by this macro definition:
#define HIWORD(l) ((WORD) (((DWORD) (l) >> 16) & 0xFFFF))
Couldn't the same effect be achieved with the following?
The standard says this:
"Dependent name resolution [temp.dep.res]
1 In resolving dependent names, names from the following sources are considered:
— Declarations that are visible at the point of...
Thanks. That's reassuring. I wonder though whether the declaration of f(float) wouldn't in fact have to be before the template definition to be considered, since floats don't have an associated...
#include <iostream>
using namespace std;
void f(const char*)
{
cout << "f(const char*)\n";
}
template <class T> void g(T a){f(a);}
Nicely put. I see now where I went wrong, I think.
And if the function took an argument of the same pointer type, it would presumably be declared as follows:
int (*(fun(int(*)(int)))) (int);
Thanks. That's what I ended up doing. I am still puzzled as to why my initial declaration didn't work though. I can't see any difference between it and the typedef version, other than that the latter...
Hello,
I am getting a compilation error for this:
int(*)(int)fun();
What I am trying to declare is a function that returns a pointer to a function taking an int argument and returning an...
ns::fn(x); // error: ns::fn not found
gcc does seem to find ns::fn() even if it's not supposed to (it also finds fn() with the unqualified call using argument-dependent lookup).
If fn() really...
I actually don't find it that dry; the author even makes the odd joke in places, which is more than can be said for e.g. K&R.
I am trying to decipher the following paragraph from chapter 11.5.1 of Bjarne Stroustrup's The C++ Programming Language:
"A friend class must be previously declared in an enclosing scope or...