For some time now, I have been learning about writing GUI apps under Win32.
This is far from complete, and it needs a lot of cleanup.
Some of the code still crashes, probably. (especially the WM_SETTINGCHANGE/WM_THEMECHANGED code) :red
But, I thought you guys might like to play with it, anyways.
This is a special version that records all messages received in window A and displays them in window B.
I needed this version to help develop the WM_SETTINGCHANGE/WM_THEMECHANGED stuff. :P
DAVE !!!
I've been reading through your code. I'm assuming this is a work in progress.
The first time I launched the executable,...I almost screamed,...you should probably recommend that people wear special dark sunglasses before launching (Ha,...ha,...).
I like your approach, however. The average windows programmer does not do all that initialization. And, so, typically, applications hang for no apparent reason.
Once I get a clearer understanding of what your code is doing, I'll have some annoying questions. But, for starters,...I'm wondering why the Save As... menu selection doesn't launch a Save File dialog box. You've got it all set up,...your FSaveAs Proc is just waiting to execute, and, then the code execution jumps elsewhere.
Anyway, thanks for posting,...it's interesting to see how an assembly programmer approaches the problem.
actually, File Save As works great - lol
i was having a problem with the Clear Screen function
i use the Form Feed character to CLS
i had temporarily pointed the Save As ID in WM_COMMAND to a little form feed function for testing
that way, i could print a form-feed with a menu-click
it should be...
cmp eax,IDM_FILE_SAVEAS ;32
jz Cmmnd2
and remove the little piece of code it was pointing to - "xxxx00" or something
and, to fix the Form Feed....
dTxtOE: mov edi,BlockUsed
xchg eax,edx
mov ecx,BufCalc4 ;RowLength*BufferRows/4
mov LocCntX,eax
rep stosd
mov LocCntY,eax
or byte ptr dUpdateFlags,7 ;<---- add this line
jmp dTxtO0
it cleared the buffer - but did not update the screen :P
it still has a few little bugs
for example, if the screen is empty, copy to clipboard crashes
i can fix that one easily - lol
since i posted that one, i have done a lot of work on it and cleaned it up
I'll keep reading. It's alot of code for a typical set-up,...undoubtedly, I've missed all the cool stuff (which I probably won't really understand, anyway).
Just out of curiosity, how is the user supposed to clear the screen ???
And, what is copy Forum, from the pop-ep menu ???
You've already got the code in your program,...it's just not connected in correct sequence. A very easy way to clear the screen is InvalidateRect and UpdateWindow.
I noticed that you don't invoke BitBlt Function (http://msdn.microsoft.com/en-us/library/dd183370(v=vs.85).aspx) anywhere in your code. It's very easy to use.
Here's a very good example of this, that I stole from QWORD: BitBlt_Example (http://www.masm32.com/board/index.php?action=dlattach;topic=17109.0;id=9568)
Mysteriy functions are my specialty,...if you want some suggestions,... :eek
the init section is a little long because i enumerate the font and create all the menus with code (instead of resource)
also, i save a bin file to restore the previous view settings on start-up
normally, to clear the screen, you'd...
dPrint chr$(12)
if you want to make it do something different....
at the beginning of the file, turn off the test text generators....
static_ctrl EQU 0
thrd_ctrl EQU 0
then, have a look at the UserCode.inc file
call OpnPres ;open presentation mode window
this generates a status bar message with the time and enables file-save and copy to clipboard functions
call TestComplete
the dPrint macro works like the masm32 print macro and prints to the User mode window
this will print to the PM window....
INVOKE rPrint,offset MsgBuff
i have a macro for that, now, but not in the posted one
put this code in the UserCode.inc file...
.DATA
TestStr db 'Presentation Mode',13,10,0
.CODE
UsrCode PROC
call OpnPres ;open presentation mode window
dPrint chr$('User Mode'),13,10
INVOKE rPrint,offset TestStr
call TestComplete
ret
UsrCode ENDP
then, build it
i have thought about using a back-buffer
i had one in there some time back, but took it out
i was trying to keep the use of system resources to a minimum
but, i like the way it worked - i will probably put it back in there :P
if you notice, the text output is pretty fast - at least to the local window
haven't really speed-tested the PM window :lol
to send text to the PM window, i use WM_COPYDATA
and, there is an acknowledge message coming back
for now, there aren't many "commands" - i will add them as i go
...Well,...I found dPrint:
dPrint MACRO arg1:REQ,varname:VARARG
INVOKE dTxtOut,reparg(arg1)
IFNB <varname>
INVOKE dTxtOut,chr$(varname)
ENDIF
ENDM
...But, I have no idea what dTxtOut is. I'm assuming that it is like: TextOut Function (http://msdn.microsoft.com/en-us/library/dd145133(v=vs.85).aspx)
Hey, Dave, don't feel compelled to respond to all my comments,...so far, I've just got a vague concept of what I'm reading,...fragments in my mind,...
When I am initially setting up the grunge code for a Windows project, I typically do it the easiest possible way,...just to get it ti work. And, then, I rethink it and improve it where it seems necessary. It's not a great technique,...
it's a function in the main program file - has lot's of read-me text :P
you can add another macro for the PM window...
xPrint MACRO arg1:REQ,varname:VARARG
INVOKE rPrint,reparg(arg1)
IFNB <varname>
INVOKE rPrint,chr$(varname)
ENDIF
ENDM
And, these repaint the client rectangle ???
What might be a good idea is to have a screenshot function. They are kind of a pain in the ass to code initially, but, once you've got it, you can use it anywhere,...like, instead of an invoke of UpdateWindow,...and the user can't tell what kind of cool stuff is happening behind the scenes. I'm guessing that either Vortex ofr EDGAR has one.
hang on, i'll write you a little demo (without all the WM_ message stuff).....
Yeah,...here's an almost complete routine from Vortex: Convert Memory Bitmap to JPEG (http://www.masm32.com/board/index.php?topic=14200.msg112730#msg112730)
I will, of course, expect some serious recognition for stealing code from the more experienced MASM Forum members (Just kidding).
EDGAR has an entire library of these functions if you visit his site: Graphics Lib Zip (http://www.quickersoft.com/donkey/files/Graphics.zip)
here you go
i have renamed the macros to "uPrint" and "pPrint"
have a look in the UserCode.inc file....
This is a thing of beauty. Thanks Dave for your infinite patience.
I gotta run,...my day is almost done.
thanks :bg
wait til i'm done adding the rest of the code
the real reason i started this project about 10 months ago - lol
just as i started writing it, i decided i wanted it to be a GUI app
so, i have been trying to learn GUI ever since
(http://img707.imageshack.us/img707/9821/2001gc.png)
If you are interested,here is an array of messages ( generated by my IDE)
Need only 3 lines of code to retrieve it.
thanks, Yves
i use a list and function that i wrote a while back
it is similar to the FormatMessage function
http://www.masm32.com/board/index.php?topic=16460.msg137899#msg137899
i see your list has some messages that i am missing, though :U
I learned to program Windows (in C++) by reading these two books:
- Programming Windows, 5th Edition by Charles Petzold, 1998 (http://www.charlespetzold.com/pw5/)
- Windows Graphics Programming: Win32 GDI and DirectDraw, 2000 (http://www.fengyuan.com/)
Both are somewhat dated, but, are excellent otherwise. Feng Yuan's book, especially explains the basics of Windows graphics thoroughly. Chapter One is: Here (http://vig.pearsoned.com/samplechapter/0130869856.pdf). Both books come with a CD containing all the source code examples from the book.
Translating C++ code into assembly language is straitforward,...you just invoke Windows graphics API functions in sequence. Even a nitwit like me can do that,... :eek
As you've probably noticed,...there aren't any books about assembly language Windows graphics programming. This forum is the source for the entire world.
thanks for the sources
i think we've all seen Petzold's examples at one point or another :U
i managed to find Yuan's book in CHM form....
http://www.4shared.com/file/j6QT3Spd/FengYuan.html
i'll give it a look
for me, i don't have a real problem displaying stuff :bg
my problem in that department is the tedious code that decides which part of the screen requires update, if any
i took some shortcuts in that regard and got decent results
for now, that's good enough
i can move on with the rest of the project and come back to that later, if desired
up to this point, i have been using it as a test-bed for learning how windows works
i have spent a lot of time "playing", really
which is, in some ways, a good way to learn
this particular version of the program was a "proof of concept" for me
i wanted to see if i could use WM_COPYDATA to talk between 2 different applications, and to see how fast it was
my code in that area is a bit rough - i kind of threw it together
but, i set up a minimal communications protocol with message/acknowledge handshaking
just to see how it would go :P
i added a "continue" command to keep long messages from timing out
and a "flush" command for error recovery
i may add a "resend request" command to use in recovery of missed messages
at this point, i haven't missed any messages, though - lol
there is a small problem here, and that is sequencing (or synchronizing, if you prefer) messages
the method i am using now sequences messages in a half-duplex mode
(i.e. messages received in window A are handled in the same order as they were sent from window B,
messages received in window B are handled in the same order as they were sent from window A)
i haven't figured out an efficient way to sequence them full-duplex, and i am not sure i need to
The more I read from your application, the more I understand. It's good stuff,...
Regions (http://msdn.microsoft.com/en-us/library/dd162913(v=VS.85).aspx) (MSDN refers to these as Legacy Graphics) are a pain in the ass. Just enumerating them is tedious and memory intensive. Often, they are used used to perform hit testing.
I was in the process of writing a DirectX application that edits meshes (which you use alot in 3D), and, when I got to the point where I had to implement a variable number (usually large) of regions that conform to the sides and vertices of triangles displayed on the screen, so that the user could select an element to edit with a mouse click, I just realized that it was going to be enormously time consuming (possibility of dying of old age), and, I decided to take a vacation.
When I want to communicate between two applications,...I just write a text file, and put it in an obvious place, then delete it when I'm done. It's dumb, but, it works. Of course, this is not production code, and I don't have to worry about customer support.
yah
i chose to stick with mono-spaced system fonts
that really simplifies the code
my paint code does a good job of painting text only inside the update rectangle
but, i took the lazy way out when it comes to telling the OS which areas to include in that rectangle - lol
if/when i put the back buffer code in there, the current paint code should be helpful
because i used mono-space fonts, the whole thing is still pretty fast, even with my short-cuts
beyond fixing the update method and adding a back-buffer, extending font capability is an area with room for improvement - lol
i could also offer something like the console in the way of character-cell attributes
i have no intention to go beyond text with this particular application - so no "real" graphics stuff :P
have you tried Ctrl-Wheel ?
Quote from: DAVEhave you tried Ctrl-Wheel ?
Ah, yes, your zooming code. Seems I vaguely remember a thread on that subject. And, no, I've never used it, sorry.
I'd probably do it in some more cumbersome way,...
My current crackpot theory is that competent programmers are just making reality TOO EASY for consumers,...and this is a major reason we have so many obese people in America,...(I tried to convince EDGAR of this,...and, now, he thinks ALL Americans are whackos,...)
i was lazy, again, when it came to handling the mouse wheel - lol
i calculate the movement......
..... and use PostMessage to make it scroll :lol
simplified the code, and it seems to work fine