Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Stupid Windows API

 
Post new topic   Reply to topic Printable version
 View previous topic  Being hammered by exploited hosts Post :: Post ram error  View next topic  
Author Message
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sat Apr 09, 2005 10:36 am   Post maybe stupid    Post subject: Stupid Windows API Reply to topic Reply with quote

OK, I have to revamp a bit of WM_COMMAND-processing code I wrote for a new feature in a program I'm writing.

Now, it just so happened before that I didn't have to process a BN_CLICKED and a menu item click before, but now that I do, is it true that they both have a notification code of 0?!

MSDN Library wrote:
The high-order word specifies the notification code if the message is from a control. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero.

winuser.h
Code: Show/Hide
/*
* User Button Notification Codes
*/
#define BN_CLICKED          0 //same as menu item click??
#define BN_PAINT            1 //same as accelerator message??
#define BN_HILITE           2
#define BN_UNHILITE         3
#define BN_DISABLE          4
#define BN_DOUBLECLICKED    5


If this is true, I guess I'm just going to have to handle both of them in the same case statement and just differentiate by ID? How messy.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat Apr 09, 2005 10:40 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

All commands should be handled by code AND id, otherwise you can confuse lots of messages. You can differentiate between menus, accelerators, and control notifications.
_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sat Apr 09, 2005 1:56 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Yeah, don't worry, I haven't been doing it just by code, I've been doing it by MAKELONG() with the full wParam. But sadly I can't do that now, since I'm processing the EN_SETFOCUS and EN_KILLFOCUS messages, and I somehow don't want to make a case for every single edit control I have.

What I find messy is simply this:
Code: Show/Hide
   switch (code)
   {
   case BN_CLICKED:   //and menuitem click!
   case CBN_SELCHANGE:   //and accelerator!
      switch (id)

I don't see why MS couldn't just allocate a range of numbers for each control. I mean, I really doubt that there are more than 65535 notifications, and the newer ones use WM_NOTIFY.

Anyway, thanks.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat Apr 09, 2005 2:44 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Yes I have often thought the same thing. In my command handler, I use if/else-if/else-if/else type statements. Doesn't have to be super efficient because commands are mostly at UI speed (ie user keys and clicks).

If you were ambitious, you could also combine code/id into a single value and switch on that.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sat Apr 09, 2005 3:53 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Ekted wrote:
If you were ambitious, you could also combine code/id into a single value and switch on that.

Yeah, that was what I was trying to say I had been doing above, but now I have many, many IDs for the same notification code, and I want to process them all the same.

(Are we the only Win32 programmers on this board?)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Sun Apr 10, 2005 1:41 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Cyan~Fire wrote:
Are we the only Win32 programmers on this board?

No, just my UI skills are just crap. Take a look at 'pretty' the interface for my DeBuildlevel program was. I prefer to try and work on the background side of things, and leave the interface to someone else.

Of course, I've been working on trying to increase my UI skills, but have not had the time too much.
Back to top
View users profile Send private message Add User to Ignore List Send email
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Sun Apr 10, 2005 3:48 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Mine GO BOOM wrote:
No, just my UI skills are just crap.

Hah, if you call yours "crap" you haven't seen mine yet. sa_tongue.gif
Every time I try to get a nice GUI on a program I end up getting annoyed because things don't work how I want them to work or just, well, don't work at all. icon_sad.gif
I might start trying to skills ^ 2 again after this school year.
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sun Apr 10, 2005 5:14 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I didn't even know where to begin, most of the pages I lookup uses MFC or some variant of it.
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sun Apr 10, 2005 5:32 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

MFC is like a virus. It took over Win32 API without improving it. It now dominates all searches for any real info.
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sun Apr 10, 2005 8:53 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I had a go at some GUI stuff last weekend. I had to port my code to c++ since that's what wxWidgets uses. It made the program 5 times bigger.
When I got round to installing the wx devpak in devcpp the barebones program int the project template is 1.8mb (statically linked I believe). The gtk libs were over 6mb themselves so wx is an improvement in a way.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sun Apr 10, 2005 9:29 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

My win32 apps (statically linked) are usually in the 20-60K area, unless they have a ton of resources in them.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sun Apr 10, 2005 11:00 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Eek. My program is 100K! It's dynamically linked, which by my understanding, should make it smaller? What's wrong?
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Mon Apr 11, 2005 12:48 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Straight win32? No other non-OS libs? No wrappers like MFC, etc? Large resources? Release mode compile?
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Mon Apr 11, 2005 1:40 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Mr Ekted wrote:
MFC is like a virus. It took over Win32 API without improving it. It now dominates all searches for any real info.


Time to write your book now icon_wink.gif show us newb programmers how to do it right tongue.gif
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Apr 11, 2005 5:46 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Well, I am using zlib.

Code: Show/Hide
## Makefile for AOK Trigger Studio by David Tombs

#Check for CFG macro

!IF "$(CFG)" == ""
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
!MESSAGE
CFG=Win32 Debug
!ENDIF


#Release build
!IF  "$(CFG)" == "Win32 Release"

OUTDIR=.
INTDIR=.\Release

CPPFLAGS_OPT = -ML -O2
LINK32_FLAGS = /release /incremental:no

#Debug build
!ELSEIF  "$(CFG)" == "Win32 Debug"

OUTDIR=.\Debug
INTDIR=.\Debug

CPPFLAGS_DEBUG = -MLd -Gm -D "_DEBUG" -FAs -Fa"asm/" -Zi -Fd"$(INTDIR)\\"
LINK32_FLAGS = /debug /pdbtype:sept
RFLAGS_DEBUG = /D "_DEBUG"

!ELSE

!ERROR Invalid configuration "$(CFG)" specified.

!ENDIF

LINK_LIBS=zlib.lib user32.lib comdlg32.lib comctl32.lib advapi32.lib
CPPFLAGS = -c $(CPPFLAGS_DEBUG) $(CPPFLAGS_OPT) -YX -Fo"$(INTDIR)\\" -D WINVER=0x0400 -EHsc -W3
RFLAGS = /fo "$(INTDIR)\AOKTS.res" $(RFLAGS_DEBUG)

LINK_OBJS = \
   $(INTDIR)/aokts.obj \
   $(INTDIR)/datatypes.obj \
   $(INTDIR)/editors.obj \
   $(INTDIR)/scen.obj \
   $(INTDIR)/scen_const.obj \
   $(INTDIR)/trigedit.obj \
   $(INTDIR)/ecedit.obj \
   $(INTDIR)/utilui.obj \
   $(INTDIR)/zlibfile.obj \
   $(INTDIR)/unitedit.obj \
   $(INTDIR)/trigger.obj \
   $(INTDIR)/utilio.obj \
   $(INTDIR)/AOKTS.res

#Inference Rules

.cpp{$(INTDIR)}.obj:
   cl $(CPPFLAGS) $<

.rc{$(INTDIR)}.res:
   rc $(RFLAGS) $<

#Targets

build: $(OUTDIR)\aokts.exe
   @echo Build complete.

source: $(OUTDIR)\source.zip
   @echo Source zipped.

#Build targets

$(OUTDIR)\aokts.exe: $(LINK_OBJS)
   link.exe $(LINK32_FLAGS) /out:"$@" /pdb:"$(OUTDIR)\aokts.pdb" $(LINK_LIBS) $(LINK_OBJS)

$(LINK_OBJS):

#Source targets: yes, this is a stupid version of a batch file.

TEMPFILES=aokts.cpp datatypes.cpp editors.cpp scen.cpp scen_const.cpp trigedit.cpp utilui.cpp zlibfile.cpp ecedit.cpp unitedit.cpp

$(OUTDIR)\source.zip: *.cpp *.h aokts.rc src_notes.txt MAKEFILE res\aokts_big.bmp res\aokts.ico
   @"C:\Program Files\7-zip\7z" u $(OUTDIR)\source.zip $**

!INCLUDE makefile.dep
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Mon Apr 11, 2005 5:58 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

My static zlib.lib is 66K in release mode. It's a build I made with just the stuff I've used. For example, I don't use the file stuff. I have no idea how much bigger this lib makes the EXE though.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Apr 11, 2005 6:30 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

The dynamic one with all the functions I'm using is 10.5K.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Mon Apr 11, 2005 6:55 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Dynamic means the EXE will use an external DLL.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Apr 11, 2005 7:52 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

But it still needs a lib to link to, right? I looked in zlib.lib with a hex editor, and it seems it's just a bunch of function names and offsets.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Mon Apr 11, 2005 8:11 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

A dynamic lib simply lists the exports that are in the DLL. This allows the linker to know that they exist, and to place the appropriate references in the EXE header so the loader knows to load zlib.dll and what functions to find/resolve.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Apr 11, 2005 8:45 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

OK, that's what I thought. So... any clue what's going on? The source itself is 160K, if that's around the range you're looking for.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Mon Apr 11, 2005 9:39 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

You use anything gay like STL?
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Apr 12, 2005 3:55 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I don't use STL, but I use one template class that I wrote. I guess that does take up a bit of room, as it's used for 4 different classes, so 4 different copies.

But it's nowhere near STL which includes around 10 templates for one you use in your code.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Jun 20, 2005 9:05 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Off topic, but still Stupid Windows API.

Any way to catch a return sent to an edit control other than by subclassing? Of course, only common controls send NM_RETURN (not to mention WM_NOTIFY in general, which only makes command processing 50 times easier).
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Trash Talk All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 195 page(s) served in previous 5 minutes.

phpBB Created this page in 0.806264 seconds : 49 queries executed (74.4%): GZIP compression disabled