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
Lenophis

Super Koopa
Level: 44

Posts: 464/830
EXP: 584360
For next: 26925

Since: 03-15-04
From: Duluth, MN

Since last post: 4 hours
Last activity: 3 hours
Posted on 05-11-05 11:21 AM Link | Quote
Originally posted by R2H2
Everything else is working now though although I haven't tried menus yet...

I can assure you, menu's are easy. Although, I haven't figured out how to add icons to the selections yet. It's probably easy, but I haven't really tried to look into it yet.

EnableMenuItem(GetMenu(hWnd), (id of control), (flags));

Flags:
  • MF_BYCOMMAND
    Indicates that uIDEnableItem gives the identifier of the menu item. If neither the MF_BYCOMMAND nor MF_BYPOSITION flag is specified, the MF_BYCOMMAND flag is the default flag.
  • MF_BYPOSITION
    Indicates that uIDEnableItem gives the zero-based relative position of the menu item.
  • MF_DISABLED
    Indicates that the menu item is disabled, but not grayed, so it cannot be selected.
  • MF_ENABLED
    Indicates that the menu item is enabled and restored from a grayed state so that it can be selected.
  • MF_GRAYED
    Indicates that the menu item is disabled and grayed so that it cannot be selected.


Simple example of how to disable and enable any given menu option. From my experiences, I use the MF_BYCOMMAND flag.


(edited by Lenophis on 05-10-05 06:23 PM)
(edited by Lenophis on 05-10-05 06:24 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: 4487/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-15-05 02:17 AM Link | Quote
Hm, how do I add the menus? I made one with ID 1, set the dialog's Menu to 1, and compiled it, and DialogBox fails with error 13 (invalid data). Looking at it in Resource Hacker, the script doesn't seem to make any sense. It's all chopped up.
1 MENUEX
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
{
POPUP "Vegetable", 1, MFT_STRING, MFS_ENABLED, 0
{
MENUITEM "Pota", 100, MFT_STRING, MFS_ENABLED
POPUP "", 0, MFT_BITMAP | MFT_MENUBARBREAK | MFT_MENUBREAK, MFS_ENABLED, 0
{
MENUITEM "", 116, MFT_STRING | MFT_MENUBARBREAK | MFT_MENUBREAK, MFS_DISABLED
POPUP "lery", 128, MFT_STRING, MFS_DISABLED, 0
{
MENUITEM "imal", 129, MFT_STRING, MFS_DISABLED
MENUITEM "", 0, MFT_STRING, MFS_ENABLED
}
POPUP "", 99, MFT_STRING, MFS_ENABLED | MFS_CHECKED, 0
{
MENUITEM "", 201, MFT_STRING, MFS_ENABLED
POPUP "", 114, MFT_STRING | MFT_MENUBARBREAK | MFT_MENUBREAK, MFS_GRAYED, 0
{
POPUP "nda", 128, MFT_STRING, MFS_DISABLED | MFS_CHECKED | MFS_HILITE, -1865940796
{
}
}
}
}
}
}


The menu being laid out like so:
Vegetable [ID 1]
-> Potato [100]
-> Carrot [101]
-> Celery [102]
Animal [2]
-> Chicken [200]
-> Kangaroo [201]
-> Panda [202]

(The same happens if I don't set an ID, just making them all 0...)


(edited by R2H2 on 05-14-05 09:22 AM)
Parasyte

Bullet Bill
Level: 35

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

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 05-15-05 02:51 AM Link | Quote
That does not appear to be a properly formatted resource.
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: 4489/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-15-05 08:05 AM Link | Quote
Well that makes two of us who think so. Dammit. I don't want to have to find another whole resource editor just because this one can't make a menu properly... Maybe I'll just hack up something to generate them at runtime. That being said, er... how do you do that? I've made a right-click popup menu before, it's just a matter of how to make it the window's menu.

[edit] Come to think of it... I'm completely clueless about keeping track of controls over multiple dialogs. Like what if I have 2 controls on 2 different dialogs with the same name? The only solution I can think of is to include the dialog's name in every control's name, which would make it rather tedious having to type out the entire thing every time. And if dialog 0 has a button as control 1, and dialog 1 has an edit box as #1, then when I go to reference the controls, how do I differentiate between them? Then there's the handle issue. To call GetDlgItem or whatever it was every time I need to reference a control would probably be really slow, so I've been keeping an array of each control's handle referenced by its ID. Of course, having multiple dialogs again brings up the issue of multiple controls sharing an ID, meaning the only feasible way to do such a thing would be something like a 2D array indexing by both the dialog's ID and the control's, and that again has the problem of having to type out the dialog's name every time you reference a control.


(edited by R2H2 on 05-14-05 06:16 PM)
Parasyte

Bullet Bill
Level: 35

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

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 05-15-05 07:47 PM Link | Quote
Originally posted by R2H2
To call GetDlgItem or whatever it was every time I need to reference a control would probably be really slow, so I've been keeping an array of each control's handle referenced by its ID.


Therein lies your problem; GetDlgItem() is not slow. The overhead produced by it is completely negligable (on the order of a few microseconds). Use it. It will save you a lot of trouble. And it won't cause you any. Isn't that great?
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: 4497/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-16-05 07:32 AM Link | Quote
Well that's certainly good, but it still means having to include the dialog's name... Am I to assume there's no way around that? Or has being up for 32 hours affected my thinking and I'm totally wrong here?
Parasyte

Bullet Bill
Level: 35

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

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 05-17-05 06:48 AM Link | Quote
You don't use the dialog's name with GetDlgItem(); you use a window handle and control ID. The control ID is an integer, though resource editors usually create "resource.h" files with #defines for each control ID. In my opionin, such methodology is a huge waste of time. But that doesn't change the fact that you'll only be passing a window handle and an integer ID. No "names" involved.
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: 4504/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-18-05 04:38 AM Link | Quote
Well by name I meant the #define; I generally use those. Easier to keep track of. (I could swear I've had this conversation before... ) Good to know, though. However, there's still the problem of having multiple controls with the same 'name' on different dialogs. Is there something similar to VB's 'with' statement perhaps? I might be able to work with that.


(edited by R2H2 on 05-17-05 01:55 PM)
Parasyte

Bullet Bill
Level: 35

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

Since: 05-25-04

Since last post: 104 days
Last activity: 32 days
Posted on 05-18-05 09:16 AM Link | Quote
Most people prefix their defines for this very reason! If you have a button you want to define as "OK", prefix it so you know it's a button, and which dialog it is on:

#define MAINDLG_BTN_OK 100


As you can imagine, it could tend to get cluttered. Thus bringing to light the reason I perfer to just use the number and add comments to explain what's what.


(edited by Parasyte on 05-17-05 04:17 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: 4517/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-19-05 05:07 AM Link | Quote
Heh, that's what I ended up doing.
How can I get a dialog's ID in DialogProc? GetDlgCtrlID returns 0 for every dialog. Nevermind, I'll just use CreateDialogParam.

[edit] Small structure-related problem. I'm reading a structure out of a binary file (a ROM). I've re-created the structure exactly, and simply use fread() to read data from the ROM into the structure as a single element of the number of bytes it takes up in the ROM - I added more to the end so I can't use sizeof()). For the most part it works, but the structure actually contains another, smaller structure in it, and this isn't being read right. The sub-structure consists of one byte and one short. (FYI, the short is stored low-byte-first in the ROM, which I assume is the same as in memory.) Is there like extra bytes stuck in there to hold information about the sub-structure or something?

Code segments:
typedef struct _ROMPtr
{
BYTE Bank;
short Addr;
} ROMPtr;

struct MapHeader
{
[...]
BYTE YSize; //Height (this comes first O_o)
BYTE XSize; //Width
ROMPtr _MapLoc; //3-Byte pointer to map
ROMPtr _ScriptLoc; //3-Byte pointer to on-load script
short _EventLoc; //2-Byte pointer to event data (shares bank with ScriptLoc)
BYTE ConnectionFlags; //Connection flags
} MapData;


XSize and YSize both get read fine, as well as everything else before them (which is omitted), but _MapLoc and everything after that seem to be getting corrupt. (MapLoc's members should read 0x2B and 0x4DB5, but they're reading as 0x2B and 0x4D48. ) I'm not really sure if it's actually everything after them though, or just those themselves, since that's all at the very end of the structure (only ConnectionFlags really provides any indication, and it's 0, which is right, but so is most of _ScriptLoc and _EventLoc, which is wrong.)

Also, what's the use of 'MapHeader' in 'struct MapHeader'?


(edited by R2H2 on 05-18-05 12:14 PM)
(edited by R2H2 on 05-18-05 03:29 PM)
sloat

Level: 16

Posts: 49/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-19-05 09:09 AM Link | Quote
your compiler is probably aligning the memory along a 4-byte boundary. normally, this would be ok (it's actually more efficient for a cpu to have memory set up this way), but since you're reading the data straight in to it, it's not going to work out very well.

you can try adding the line:
#pragma pack(1)

before all of your struct definitions. if that doesn't work though, check out your compiler's docs for the correct switch to set.
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: 4529/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-20-05 03:47 AM Link | Quote
Cool, that did it.

[edit] Hopefully someone decides to look in here again for whatever reason. Just have a few relatively simple questions:

1) Where can I find examples of using functions in .dll files?
2) Is it possible to include the line number and filename in a string? I often see programs listing these in debugging info, and to have to go through and update them all manually every time you modify a file would be pretty tedious. [edit: yay for __FILE__ and __LINE__... Can I get just the filename and not the full path though?]
3) Is there a way to get the names of days, months etc? (I could hard-code them, sure, but then they'll always be in English.)
4) Using that #pragma pack(1) statement, will that pack everything to one byte? If so, how can I restore the default setting afterward? I only want these particular structs packed that way.

Probably more to come...


(edited by R2H2 on 05-20-05 08:04 PM)
(edited by R2H2 on 05-20-05 08:07 PM)
(edited by R2H2 on 05-20-05 08:12 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.009 seconds.