ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > T-Clock

T-Clock 2010 (download)

<< < (2/169) > >>

f0dder:
Hm, just did a silly little test - obviously won't work runtime, but compiles clean with the following two compilers (VS2008 + SP1):
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86

...should work fine for older compilers as well, although there is a PlatformSDK dependency to have GWLP_* work (dunno when that was introduced, but iirc it works fine on VS2005).

Note that I prefer the C++ style cast operators, but C style (cast) just as well (they're less explicit and harder to grep for, though, and the C++ operators allow you to be more precise wrt. what/why you're casting).


--- Code: C++ ---#include <windows.h> extern HWND hwndClock;extern LRESULT CALLBACK newWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); int main(){        WNDPROC oldWndProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hwndClock, GWLP_WNDPROC));        SetWindowLongPtr(hwndClock, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(newWindowProc));}

Stoic Joker:
Hm, just did a silly little test - obviously won't work runtime, but compiles clean with the following two compilers (VS2008 + SP1):
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86-f0dder (March 03, 2010, 06:35 AM)
--- End quote ---
I'm like totally open for suggestions here. ;)

...should work fine for older compilers as well, although there is a PlatformSDK dependency to have GWLP_* work (dunno when that was introduced, but iirc it works fine on VS2005).
--- End quote ---
It does, and is used/was required to get the origional (VS2k5) project off the ground

Note that I prefer the C++ style cast operators, but C style (cast) just as well (they're less explicit and harder to grep for, though, and the C++ operators allow you to be more precise wrt. what/why you're casting).
--- End quote ---
That decision was made for me as the origional (authors) code is pure C, which I haven't changed ... But have regretted more than once...

Daleus:
Stoic,

Sorry I can't offer any programming tips, but I did want to chime in and say that TClock has been one of my must have programs for a couple of years now.

Take this as encouragement that I'd love to see your latest version when it becomes available!

Stoic Joker:
f0dder - After going through and tidying up the various pointer castings TC2010 is proving to be quite stable. I've even spent some quality time trying to crash it, and happily failed. Rather odd side note is that the strange behavior of the Mouse Tab of the Properties Dialog crashing the program seems to have disappeared. So I've tentatively (also) crossed that Bugg off the To-Do list for the moment. :)

Daleus - Thank You, I truly appreciate the encouragement. I got hooked on TClock back in the late 90s and am completely incapable of parting with it. If you are interested in a bit of (alpha/) beta testing ... I could be easily coerced into posting a download of TC2010 once I get a few more things ironed out. ;)

mwb1100:
this is a pointer, except, like... it's an integer
-f0dder (March 03, 2010, 01:53 AM)
--- End quote ---

As I'm sure you know, it's quite common in C to store pointers in int variables.  While this might not be a good practice in general there are times when it makes sense, such as for SetWindowLongPtr() where all the API is interested in is storing a small blob of data - it doesn't care what that data is (the user of the API gets to decide what the data means).

The intent of the LONG_PTR/ULONG_PTR types is the same as C99's intptr_t and uintptr_t types which is to be able to declare an integer type that can hold a pointer - exactly for situations like Win64 where pointers are larger than normal ints. The C99 standard calls them "Integer types capable of holding object pointers".

On the other hand, Microsoft should have made it so that passing a LONG_PTR type (whether by casting or not) to SetWindowLongPtr() should not have caused a warning whether the build was for 32 or 64 bit. That's really where something fell down here.  The whole point of a type like LONG_PTR is so that the conditional code that Stoic Joker ended up using wouldn't be necessary.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version