News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Project Preview - dTest

Started by dedndave, August 02, 2011, 09:09:20 PM

Previous topic - Next topic

dedndave

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

baltoro

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.
Baltoro

dedndave

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

baltoro

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 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
Mysteriy functions are my specialty,...if you want some suggestions,... :eek
Baltoro

dedndave

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

baltoro

...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

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,...
Baltoro

dedndave

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

baltoro

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.
Baltoro

dedndave

hang on, i'll write you a little demo (without all the WM_ message stuff).....

baltoro

Yeah,...here's an almost complete routine from Vortex: Convert Memory Bitmap to JPEG
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
Baltoro

dedndave

here you go
i have renamed the macros to "uPrint" and "pPrint"
have a look in the UserCode.inc file....

baltoro

This is a thing of beauty. Thanks Dave for your infinite patience.
I gotta run,...my day is almost done.
Baltoro

dedndave

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

dedndave

#13

ToutEnMasm


If you are interested,here is an array of messages ( generated by my IDE)
Need only 3 lines of code to retrieve it.