Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - I need a resource editor! | |
Pages: 1 2 3 4Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4297/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 04-29-05 11:45 PM Link | Quote
Well I'm getting around 400% speeds, and I think even NO$GMB uses GDI. I will check that out though. Do you need to have some special program installed for that like with DirectX though?

I suppose 8-bit could work if I dump the palettes into it whenever they're changed.

[edit] Also how can I get the size of the window borders and title bar? CreateWindowEx() seems to be including them in the window's size, so my actual drawing area is too small.

Bah, more fun bugs. I'm writing the colours 183C4A, 397D9C, 5AB6DE and 8CEBFF. It's drawing the colours 394900, 7B9E00, B5DF00 and EFFF00. It works fine if I use 000000, 404040, 808080 and C0C0C0.


(edited by R2H2 on 04-29-05 06:48 AM)
(edited by R2H2 on 04-29-05 12:51 PM)
(edited by R2H2 on 04-29-05 05:07 PM)
Parasyte

Bullet Bill
Level: 35

Posts: 481/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 04-30-05 02:20 PM Link | Quote
Visualboy Advance can be set to use GDI. If you try it, you'll see how much slower it is compared to DirectX.
For SDL, all you need to "install" is a dll. Either place it in the directory with the SDL-reliant executable, or in your Windows System directory. Just standard dll stuff, there. For more info, check out the website: http://www.libsdl.org/

Your problem with window sizing can be solved by using AdjustWindowRectEx() before calling CreateWindowEx().

Finally, you are writing the colors backwards (BEHOLD! THE CURSE OF LITTLE ENDIAN!)
When you group the RGB color components into a 32-bit word, you must do so as in the following example:

u32 color;
color = (blue << 24);
color |= (green << 16);
color |= (red << 8);

You could also use the RGB() macro, which tends to make much more sense:
u32 color = RGB(red, green, blue);



(edited by Parasyte on 04-29-05 09:21 PM)
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4303/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 04-30-05 10:52 PM Link | Quote
Huh, that's odd... They don't look backward, and reversing them didn't help, but using RGB fixed it. AdjustWindowRectEx, however, isn't doing much of anything, which might be because for some reason 'you cannot specify the WS_OVERLAPPED style'.


(edited by R2H2 on 04-30-05 06:04 AM)
Parasyte

Bullet Bill
Level: 35

Posts: 483/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 05-01-05 03:00 AM Link | Quote
Sounds about right. Here's why:
#define WS_OVERLAPPED 0
D'oh! ;P


I wrote a quick function to resize any window by specifying the client area's width and height. It doesn't take into account scrollbars, but I figure you won't care about that, any way.

void SizeToClientRect(HWND hwnd, int w, int h) {
RECT windRect;
RECT clientRect;

//get the window and client area sizes
GetWindowRect(hwnd, &windRect);
GetClientRect(hwnd, &clientRect);

//window rect is based in screen coordinates. fix it!
windRect.right -= windRect.left;
windRect.bottom -= windRect.top;

//add the difference between client size and window size
w += (windRect.right - clientRect.right);
h += (windRect.bottom - clientRect.bottom);

//adjust the window size
MoveWindow(hwnd, windRect.left, windRect.top, w, h, TRUE);
}


Just call it from your WM_CREATE message handler: SizeToClientRect(hwnd, 640, 480); with whatever size you want the client area to be.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4304/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 05-01-05 05:39 AM Link | Quote
Thanks! If you don't mind I'm just going to copy that right in there.

[edit] Bah! Maybe there's something screwy with my computer or something. It's doing exactly the same as AdjustWindowRectEx() did.


(edited by R2H2 on 04-30-05 12:42 PM)
Parasyte

Bullet Bill
Level: 35

Posts: 484/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 05-01-05 10:59 AM Link | Quote
Debug it. After the MoveWindow() stuff, call GetClientRect() again and print the results. If it's what you expect (the params you passed as w,h) then your logic is flawed, not the computer. ;o
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4349/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 05-07-05 06:42 AM Link | Quote
Well I tried that PE Module Explorer. Very, very happy to say windres didn't have any complaints about its output, and its GUI is decent too. (Lacks some features, but ehh.) Problem is I can't get the dialog to show up. DialogBox() returns -1 and GetLastError() is 0.

/* main.h */
#define WIN32_LEAN_AND_MEAN
#define true TRUE //All-caps sucks. :p
#define false FALSE
#define not(x) x^255 //Logical not

#include
#include
#include
#include
#include "RESTEST.h"

//-----------------------Function Prototypes-----------------------
//restest.c
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine,int nCmdShow);
INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);

//Window-related vars
WNDCLASSEX WindowClass; //Window class struct
HWND hWindow = 0; //window handle
MSG msgMessage; //Window message
BOOL run = true;
/* EOF */


/* restest.h */
#define frmMain 0
#define btnClickMe 9
#define txtTextBox 2
#define lblMousePos 8
/* EOF */


/* restest.c */
#include "main.h"
char TempStr[256];

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
printf("Loading...\n");
printf("DialogBox: %d\n",DialogBox(hInstance,MAKEINTRESOURCE(frmMain),
0,DialogProc));
if(GetLastError())
printf("Error %d occurred\n",GetLastError());
printf("Bye!\n");
}


INT_PTR CALLBACK DialogProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
if(uMsg == WM_CLOSE) //Go away
{
printf("Program closed\n");
if(!EndDialog(hwndDlg,0))
{
printf("EndDialog() failed!\n");
exit(1);
}
}
else if(uMsg == WM_COMMAND) //Click
{
int ID = (wParam & 0xFFFF);
if(ID == btnClickMe)
{
GetWindowText(GetDlgItem(hwndDlg,
(int)MAKEINTRESOURCE(txtTextBox)),
TempStr,sizeof(TempStr));
MessageBox(MB_OK,TempStr,"Rawr scared yet?",0);
printf("Click!\n");
}
return 0;
}
else if(uMsg == WM_MOUSEMOVE)
{
sprintf(TempStr,"X: %d, Y: %d",(lParam & 0xFFFF),(lParam >> 16));
SetWindowText(GetDlgItem(hwndDlg,(int)MAKEINTRESOURCE(lblMousePos))
,TempStr);
}
else
return false;
}
/* EOF */


I compile like so:
echo Building resources...
windres -o resource.o "F:\Programs\Source~1\C\restest\RESTEST.res"

echo Compiling...
gcc -o restest "F:\Programs\Source Codes\C\restest\restest.c"
resource.o -mwindows -mconsole

(Some lines have been split up to not stretch the page. Anyone know how to put a horizontal scrollbar in there? )

MSDN says the function returns -1 (actually, "Â?1"; I assume that's supposed to be -1) on error, but I'm not getting any errors. I also noticed that the dialog's resource number is 0 in Resource Hacker whereas it's 1033 in most programs. [edit] Nevermind, figured that part out... Is that some sort of language select perchance? Like I could create one for English and one for Klingon, and Windows would choose the one that matches the user's language? Because that'd be really cool. [/edit] (Oh and if you're wondering about the actual code, it's just a test program. )

[edit] Interesting dump of the window messages:
WM_SETFONT 0x320A0BC2 0x00000000
WM_COMMAND 0x04000002 0x00F70194
WM_COMMAND 0x03000002 0x00F70194
WM_DESTROY 0x00000000 0x00000000
WM_NCDESTROY 0x00000000 0x00000000



(edited by R2H2 on 05-06-05 01:47 PM)
(edited by R2H2 on 05-06-05 01:49 PM)
(edited by R2H2 on 05-06-05 07:39 PM)
sloat

Level: 16

Posts: 47/85
EXP: 18044
For next: 2212

Since: 05-21-04
From: South Central Delaware

Since last post: 19 days
Last activity: 5 hours
Posted on 05-07-05 10:44 PM Link | Quote
DialogProc should return TRUE if you handle a message. What does GetLastError() return after DialogBox fails?

Also, the flags for MessageBox are the last parameter. Not that it matters in your code, since MB_OK = 0
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4375/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 05-07-05 11:05 PM Link | Quote
Ah, yes, MSDN lists the messages as returning 0, but apparently that doesn't apply to DialogProc. It's still doing it though, and GetLastError() returns 0, which really baffles me.


(edited by R2H2 on 05-07-05 06:08 AM)
Dish

Spiny
Level: 38

Posts: 396/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 05-08-05 01:11 AM Link | Quote
Are you still using 0 for the dialog ID? That's the only thing I can see that's flakey. Double check to make sure the dialog uses the proper ID in whatever resource editor you're using, and make sure 'frmMain' shares the same integer as the dialog. If you can, try changing it to something other than zero (perhaps zero has some special significance or something?)

Only other thing I can think of is maybe you have to create a parent window for the dialog -- but you shouldn't have to for Modal dialogs.

I'll put my money on the resource ID though.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4378/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 05-08-05 02:55 AM Link | Quote
No, I tried 9999 and even "frmMain" (apparently I can use strings ) but the same thing happens. DialogBox should be returning 0 if it were a problem with the parent window.
WM_COMMAND 0400xxxx means mouse down doesn't it? And 0300xxxx means mouse up? So it would seem like something is being clicked. (Judging by the 2 in the lower half, it should be a text box...) Also interesting that there's no WM_CREATE messages...


(edited by R2H2 on 05-07-05 10:01 AM)
Dish

Spiny
Level: 38

Posts: 397/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 05-08-05 04:22 AM Link | Quote
Originally posted by R2H2
DialogBox should be returning 0 if it were a problem with the parent window.


Ah, you're right. I missed that part when I looked it up.

So it's not the parent window.
It's not the Dialog Proc
It's not the HINSTANCE (at least not in the code you pasted before)

Only thing left is the resource ID -- only thing I can think of is the resource editor you're using doesn't make the dialog to have the same ID as what's defined in your header file.


WM_COMMAND 0400xxxx means mouse down doesn't it? And 0300xxxx means mouse up?


Not to my knowledge -- I don't know what those codes mean (I tried looking them up, didn't find anything). WM_LBUTTONDOWN and WM_LBUTTONUP are used for mouse clicks -- they don't go through WM_COMMAND afaik (could be wrong though... WM_COMMAND is pretty strange).


(Judging by the 2 in the lower half, it should be a text box...) Also interesting that there's no WM_CREATE messages...


Dialog Boxes don't get WM_CREATE messages (and least not if you use DialogBox). Instead you get a WM_INITDIALOG. Actually, Dialogs are half-assed windows -- not all messages get through to your message handler.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4380/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 05-08-05 05:03 AM Link | Quote
I verified it in Resource Hacker, the ID is right. I generally get errors when it isn't.
sloat

Level: 16

Posts: 48/85
EXP: 18044
For next: 2212

Since: 05-21-04
From: South Central Delaware

Since last post: 19 days
Last activity: 5 hours
Posted on 05-08-05 08:40 AM Link | Quote
Where are you getting those window messages from? You wouldn't be getting any window messages if the dialog wasn't created. If those are the only messages you're getting and in they come in that order, then it should be pretty clear that it's getting destroyed quickly.

WM_COMMAND is sending the EN_UPDATE (0x0400) and EN_CHANGE (0x0300) notifications. 0x0002 should be the control ID of the edit box. Dunno why, but it's probably just routine stuff for the edit control.

This probably won't have anything to do with it, but when dealing with GetDlgItem or related functions, you shouldn't use MAKEINTRESOURCE on the control ID. Just use the constant and you won't have to cast it as an int.

Make sure you didn't specify a class name for your dialog box.

Other than that, I'm out of ideas.
Dish

Spiny
Level: 38

Posts: 398/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 05-08-05 08:55 AM Link | Quote
Is your WM_CLOSE section being called right away for some reason? Try taking that part out, and instead have WM_COMMAND with BN_CLICKED for IDCANCEL and IDOK your close markers (which I think is what you're supposed to do anyway).
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4392/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 05-08-05 09:36 AM Link | Quote
No, I looked at that. It would output some text if WM_CLOSE executed. Not using MAKEINTRESOURCE gives the error "passing arg 2 of `DialogBoxParamA' makes pointer from integer without a cast", but doesn't seem to fix anything. How would I go about setting (or rather, making sure there isn't) a class name?

The entire output is this. I've added a bit right at the beginning of DIalogProc: printf("%08X %08X %08X %08X\n",hwndDlg,uMsg,wParam,lParam);

Loading...
005C0180 00000030 3C0A07DD 00000000
005C0180 00000111 04000002 0153064C
005C0180 00000111 03000002 0153064C
005C0180 00000002 00000000 00000000
005C0180 00000082 00000000 00000000
DialogBox: -1
Error code 0
Bye!


Also, changing DialogBox to CreateDialog, it returns 0 but still no error code. (I stuck a loop after it to keep it running until it gets a WM_CLOSE, but it just runs forever.)

[edit] Hah! I set the No Fail Create flag and now it works for the most part. The problem seems to be that some controls couldn't be created, namely the slider and progress bar. Why might that be?


[more editing fun] Have to call InitCommonControls() first, apparently. If only the INITCOMMONCONTROLSEX struct existed so I could use InitCommonControlsEx() even though it's rather unnecessarily complex instead of this apparently obsolete function.

And more fun problems arise:
-Radio buttons can all be checked at once despite having the Auto and Group attributes.
-Scrollbars don't scroll and are always at position 0.
-I can't get any text into a combo box. I add 3 strings and get the return values 2, 1, 0 (not 0, 1, 2 ) and no error code, but they're not there.
-Just how the heck do you tell what control a message is coming from in DialogProc? It doesn't contain an ID or a handle. I'm getting WM_HSCROLL messages from two different places and don't see any way to tell what's being scrolled.


(edited by R2H2 on 05-07-05 04:39 PM)
(edited by R2H2 on 05-07-05 04:44 PM)
(edited by R2H2 on 05-07-05 04:48 PM)
(edited by R2H2 on 05-07-05 04:54 PM)
(edited by R2H2 on 05-07-05 05:11 PM)
(edited by R2H2 on 05-07-05 05:22 PM)
(edited by R2H2 on 05-07-05 07:42 PM)
Parasyte

Bullet Bill
Level: 35

Posts: 504/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 05-09-05 10:36 AM Link | Quote
1) Radio buttons and Check boxes must be manually checked in WM_INITDIALOG message handler using CheckRadioButton() or CheckDlgButton().
2) Scrollbars never automatically scroll by themselves. You must handle the scroll messages to make them scroll. (see example code, below.)
3) To add text to Combo boxes, you must send the CB_ADDSTRING message to them.
4) About WM_VSCROLL and WM_HSCROLL messages:
lParam
If the message is sent by a scroll bar, then this parameter is the handle to the scroll bar control. If the message is not sent by a scroll bar, this parameter is NULL.


In the case that lParam is NULL, it means the message is coming from the scrollbar owned by the window whose messages are being handled. Since you are using scroll bar CONTROLS, lParam will contain the control ID.

Example of scroll bar handling:
case WM_VSCROLL:
GetScrollInfo(hwndDlg, SB_VERT, &si); //get the scroll info
switch(LOWORD(wParam)) {
case SB_ENDSCROLL:
case SB_TOP:
case SB_BOTTOM: break;
case SB_LINEUP: si.nPos--; break;
case SB_LINEDOWN: si.nPos++; break;
case SB_PAGEUP: si.nPos -= si.nPage; break;
case SB_PAGEDOWN: si.nPos += si.nPage; break;
case SB_THUMBPOSITION: //break; //fall through
case SB_THUMBTRACK: si.nPos = si.nTrackPos; break;
}
if (si.nPos < si.nMin) si.nPos = si.nMin;
if ((si.nPos + si.nPage) > si.nMax) si.nPos = (si.nMax - si.nPage);
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
//handle new scroll positions here, using info in 'si'
return TRUE;

Where si is declared as SCROLLINFO si; .
For scroll bar controls, the call to GetScrollInfo() and SetScrollInfo() will be a bit different. You'll pass the handle returned from GetDlgItem() and SB_CTL, rather than SB_VERT. In my case, the scroll bar is owned by the window whose messages are being handled.

And of course, the comment before the return statement is where you would handle the actual scrolling of content. Oh, and don't forget to setup the scrollbar's initial values in WM_INITDIALOG:
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = 10000;
si.nPos = 0;
si.nPage = 20;
SetScrollInfo(hwndDlg, SB_VERT, &si, TRUE);

This example will set the scroll bar range as 0 - 10000, with a page size of 20. Again, this is for a child scrollbar, and will need a small bit of changes to work with a scroll bar control.


You should really use MSDN more often, rather than trying to work things out for yourself through debugging. MSDN covers almost every topic imaginable in Win32 programming. You just have to know where to find it.


(edited by Parasyte on 05-08-05 05:47 PM)
(edited by Parasyte on 05-08-05 06:14 PM)
(edited by Parasyte on 05-08-05 06:15 PM)
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4414/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 05-10-05 08:58 AM Link | Quote
Yeah, that's the problem. Navigating a Microsoft site. I am using the CB_ADDSTRING message though.
Parasyte

Bullet Bill
Level: 35

Posts: 507/514
EXP: 267348
For next: 12588

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 05-10-05 02:44 PM Link | Quote
It's always worked for me. Here's an example using CB_INSERTSTRING, instead:
SendDlgItemMessage(hwnd, id, CB_INSERTSTRING, -1, (LPARAM)(LPSTR)"Hello world!");
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 4433/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 05-11-05 06:35 AM Link | Quote
No, that's not doing it. Could it be that I used SendMessage instead of SendDlgItemMessage? I grab all the control handles into an array indexed by their ID when the program starts, and they all look alright. Or it could be the message itself?

SendMessage(hwnd,CB_ADDSTRING,0,(LPARAM)str)

Everything else is working now though although I haven't tried menus yet...


(edited by R2H2 on 05-10-05 02:11 PM)
Pages: 1 2 3 4Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - I need a resource editor! | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.015 seconds.