Server Help

Trash Talk - Weird Code Problem

Cyan~Fire - Fri Dec 10, 2004 5:36 pm
Post subject: Weird Code Problem
My
Code: Show/Hide
INT_PTR CALLBACK IMsgsWndProc(HWND page, UINT msg, WPARAM wParam, LPARAM lParam);
//and so on...

DLGPROC procs[NUM_PAGES] =
{
   &IMsgsWndProc,
   &PlyWndProc,
   &VictWndProc,
   &DisWndProc,
   &MapWndProc,
   &UnitWndProc,
   &TrigWndProc
};


Mircosoft's
Code: Show/Hide
// The INT_PTR is guaranteed to be the same size as a pointer.
typedef _W64 int INT_PTR, *PINT_PTR;
typedef INT_PTR (CALLBACK* DLGPROC)(HWND, UINT, WPARAM, LPARAM);


Error C2440:
'initializing' : cannot convert from 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast

Apparently, the DialogProcs I'm defining myself with the same exact declaraction as DLGPROC are getting a return value of long while DLGPROC itself is getting a return value of int. Huh?? Am I missing something obvious?
Mr Ekted - Fri Dec 10, 2004 6:43 pm
Post subject:
What is _W64?
Cyan~Fire - Fri Dec 10, 2004 6:54 pm
Post subject:
I have no clue, but it doesn't matter now. icon_razz.gif Turns out that after 3 days of thinking over this, the solution pops into my head right after posting for help.

Although the file compiled right under MS Visual Studio (which I now realize I should have mentioned), it didn't work from the command line, as shown above. The problem was that the %INCLUDE% variable set by vcvars32.bat didn't have my updated MS Platform SDK before the old one inlcluded with VC. Sorry for the waste of time.

Moral of the story: Well, uhhh, I don't really know. I guess always remember that a weird error is probably old versions of include files?
Smong - Fri Dec 10, 2004 7:37 pm
Post subject:
Looks like a game, can we see screenshots or a link?
CypherJF - Fri Dec 10, 2004 8:01 pm
Post subject:
Probably an editor icon_wink.gif
Cyan~Fire - Sun Dec 12, 2004 3:19 pm
Post subject: Another Problem
OK, I know I had replied here with my 2nd weird problem but somehow it got deleted... oh well.

First of all, Cyhper's completely right. It's an editor for Age of Empires II: AOK Trigger Studio. It's in very beta stages right now, and I haven't released an update in ages, but I have put a lot of work into it. (Oh, and just for your comfort, Ekted, I am now in the process of converting from stream wrappers to the basic CRT FILE streams.)

Secondly, the main reason I replied was a strange error I was getting with the property sheet. (Since it's an editor, I just made the main window a property sheet with no parent. Yes, very cheap, I know. icon_razz.gif) Anyway, lately I had had a problem that whatever the first page was, it wouldn't be displayed until you reselected it (even though it received PSN_SETACTIVE). And the solution was just as weird.

Code: Show/Hide
WORD PropSheetButtons[] = { IDOK, IDCANCEL, IDHELP };
//remove buttons
for (int i = 0; i < sizeof(PropSheetButtons); i++)
{
   HWND hWnd = GetDlgItem(sheet, PropSheetButtons[i]);
   if (hWnd != NULL)
   {
      ShowWindow(hWnd, SW_HIDE);
      EnableWindow(hWnd, FALSE);
   }
}


The above code was in WinMain() where it had been sitting for ages with no problem. However, in a completely random move of mine, I commented it out and voila! the bug disappeared! So, I moved it down to PSCB_INITIALIZED (in my PropSheetProc), and it still worked. I'm just to let it sit there (since it does seem more sensical to me) but I'd really like to know what that was causing such a strange error.

Edit: OK, as I was reading over my post, I realized what the problem was. Lately I've been going over my code for better readability and I had changed PropSheetButtons[] from a char array to a WORD array, since that's really what dialog IDs are. However, as you can see, I wasn't dividing sizeof(PropSheetButtons) by sizeof(WORD). Oops. One of the extra data the loop read must have been the HWND to the page itself or something.
Mr Ekted - Sun Dec 12, 2004 6:58 pm
Post subject:
Quote:
I wasn't dividing sizeof(PropSheetButtons) by sizeof(WORD)


Should use: sizeof(PropSheetButtons) / sizeof(PropSheetButtons[0])
Cyan~Fire - Sun Dec 12, 2004 10:35 pm
Post subject:
Hey... that's a good idea... Thanks!

(Why can't I think of these things?)
D1st0rt - Tue Dec 14, 2004 1:12 am
Post subject:
Thats why HIS grim reaper is digital while we're stuck with analog
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group