News:

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

Scrolling issues

Started by NoCforMe, October 13, 2011, 06:15:11 PM

Previous topic - Next topic

NoCforMe

Control & text positioning is messed up. I'll have to post a screen shot from my end.

Fixed the controls going away after a minimize-restore:



CMP EAX, WM_SIZE
JE doshow

dodefault:
; use DefWindowProc for all other messages:
INVOKE DefWindowProc, hWin, uMsg, wParam, lParam
RET

doshow:
CMP wParam, SIZE_RESTORED ;Is window being shown?
JNE dodefault ;No, ignore.
INVOKE UpdateWindow, RBhexHandle
INVOKE UpdateWindow, RBdecHandle
INVOKE UpdateWindow, AddrFldHandle
INVOKE UpdateWindow, AddrSTHandle
INVOKE UpdateWindow, ChkHandle
XOR EAX, EAX
RET



You need to check for SIZE_RESTORED.

If I created these controls using the resource compiler, I'd still have to update them, wouldn't I?

I really need to get going on ResEd and the resource compiler so I don't have to continually tweak-remake-run to see small changes. Plus eliminate all that ugly window-creation code.

Have to think about how to size things. I'm requesting a fixed-pitch font (actually "Courier New") with a character height of 16 (derived by experimenting and viewing results). Not sure what exactly this means (MSDN says "logical units", so I really don't know what that means).

NoCforMe

#31
Here's what it's supposed to look like:



jj2007

Did your try invoke SendMessage, hEdit, WM_SETFONT, rv(GetStockObject, ANSI_FIXED_FONT) ?

NoCforMe

No, because I'm not using an edit control for the hex display. (But I might, as that might make it easier to edit the hex.) I selected the font into the DC. But would what you suggested work with a non-edit window, like my chilld window? In any case, setting the DC seem to work OK.

Fixed the CPU usage problem; that's what happens when you don't reply properly to a WM_PAINT message. If no file was open, I was just saying "whatever":


XOR EAX, EAX
RET


instead of calling DefWindowProc(). Doing so fixed that problem.

So jj, what can you tell me about using edit controls? (I've read the material on MSDN on them.) What I'd like to be able to do is to edit the hex values displayed. I'd want to restrict the editable area to just the hex-character field on the left and the character-display field on the right; not let the cursor go into the address display at far left. Any ideas? Suggestions for material to read?

Also, I'm still not 100% clear on how to read a large file more efficiently; should I read it in page-size chunks (320 bytes)?

qWord

Quote from: NoCforMe on October 14, 2011, 08:17:22 PMAlso, I'm still not 100% clear on how to read a large file more efficiently
Use a file mapping for large files and read it (e.g.) in chunks of 64KB (or 128k,...).
FPU in a trice: SmplMath
It's that simple!

oex

Quote from: NoCforMe on October 14, 2011, 07:14:15 PM
How do you get an image to appear in a message here (like your screen shot); do they have to be PNGs? (I attached a zipped GIF, which is kinda ridiculous, as the zip is just as big as the GIF!)

You just need to host the image online on your own webspace or on free space

We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

NoCforMe

Ah, yes. I guess I got spoiled, as the other forum I participate on provides picture albums for members to upload images and other attachments. Oh, well.

dedndave

How do you get an image to appear in a message here (like your screen shot); do they have to be PNGs?
(I attached a zipped GIF, which is kinda ridiculous, as the zip is just as big as the GIF!)


just take a PNG (or JPG or whatever) and change the extension to ZIP
then post, get a link to the attachment, and modify the post with the link as an image
i have never tried a GIF, but it probably works

the ZIP is as big as the GIF (or bigger) because they both use LZF compression
thing about LZF is, when you LZF something a second time, it usually gets bigger   :P

NoCforMe

Quote from: dedndave on October 14, 2011, 09:52:45 PM
just take a PNG (or JPG or whatever) and change the extension to ZIP
then post, get a link to the attachment, and modify the post with the link as an image
i have never tried a GIF, but it probably works

That is absolutely brilliant. Devious (love it!) and brilliant. Kicking myself for not figuring that out.

Yes, works fine with GIFs. (See above.) I was nice and named the "attachment" xxx.gif.zip to clue people in that it's not really a .zip ...

dedndave

as much as i'd like to take credit - lol
someone else figured it out
then, recently (last couple days), i saw someone use the name.img.zip format, which i thought was nice

jj2007

Quote from: NoCforMe on October 14, 2011, 08:17:22 PM
Suggestions for material to read?
The EN_CHANGE notification is good start. Here you can decide what you want to allow.

Quote
Also, I'm still not 100% clear on how to read a large file more efficiently; should I read it in page-size chunks (320 bytes)?

I guess "page-size" is the amount of bytes to display. Yes, that should do the job. The disk cache will make sure that your harddisk is not busy all the time... qWord, other ideas?

dedndave

file mapping is good, but i'd use 32Kb   :P

dedndave

as for the 120 DPI setting, i had to revert to 96 DPI and change the Appearance settings
there are too many other applications that i use that do not acquire the LOGPIXELSX/Y values to determine layout
nonetheless, a good lesson in programming methods   :P

jj2007

#43
Since I like facts more than urban legends, I wrote a little test:

- It opens a large file (Skype.exe, WinWord.exe, etc)
- it sets randomly the file pointer to a position between 0 and (size-320)
- it reads in 320 bytes

All that 100 times. The result is striking:

- For a "virgin" file, i.e. not yet used after booting, the average time to seek and read is about 8 milliseconds
- At run #2, it is cached, and the average time to seek and read drops to about 1.5 milliseconds

Having said that, it is always a good intellectual exercise to write a nice file mapping routine. With some luck, you can drop the response time to 1.2 milliseconds :bg

include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   Kill
"Deblog.txt"   ; use a fresh log file
   
stack equ <dword ptr [esp]>
   push Timer      ; reference ticks on stack
   Let esi=ExpandEnv$("%ProgramFiles%\Microsoft Office\OFFICE11\WINWORD.EXE")   ; get the WinWord file name for your OS version
   Print "Checking ", esi, CrLf$
   deb 5, "We check", $esi   ; write to log file
   
.if Exist(esi)
      Let edi=New$(320)
      void Timer
      sub eax, stack
      deb 5, "Exist", eax
      mov ecx, LastFileSize
      sub ecx, 320   ; what we can display
      deb 5, "Size", LastFileSize
      Open "U", #1, esi
      void Timer
      sub eax, stack
      deb 5, "Open", eax
      m2m ebx, 100
      .Repeat
         void Rand(ecx)
         deb 5, "New pos", eax
         Seek #1, eax
         void Timer
         sub eax, stack
         deb 5, "Seek", eax
         Input #1, edi, 320
         void Timer
         sub eax, stack
         deb 5, "Input", eax
         dec ebx
      .Until Sign?
      Close #1
      void Timer
      sub eax, stack
      deb 5, "Close", eax
   .endif
   pop eax
   Inkey "OK"
   Exit
end start

EDIT: Shortened by using ExpandEnv$