News:

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

Window Borders

Started by RedXVII, May 09, 2006, 11:55:47 AM

Previous topic - Next topic

RedXVII

Does the border aroud the richedit class becong to the rich edit class? Im trying to get a notification when the user move the mouse over the border (so the user can move the boder between the two windows) but it isnt working

I thaught it belonged to the richedit class so i did

invoke SendMessage, hwndMyRichEdit, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS

Picking up the mouse messages on WM_NOTIFY on my parent window, it works for normal mouse events. Trouble is; it doesnt work for the border. It also looks like i cant get a message from my parent windows WM_MOUSEMOVE either!

So; does anyone know how i'd get a message moving the cursor over the border?

Cheers
RedXVII  :U

ramguru

Quote from: RedXVII on May 09, 2006, 11:55:47 AM
(so the user can move the boder between the two windows)
If you mean resize richedit window while holding LButtonDown and moving mouse, I think you picked a wrong way. You should declare a region (or more) in main window, say (richedit is placed in parent like this x1=10 x2=100 y1=10 y2=100) your region would be x1=100 x2=106 y1,2 the same, and you should check that region for mouse activity. If user presses MDown you when should excute SetCapture...etc.
BTW that border probably belongs to RichEdit class, and it isn't non-client area (usually most borders are)

RedXVII

But its looks so pretty with the border

Just think how rubbish it would look with a flat single coloured line as a division.

Are you suggesting that it would send a message when the user interacts with the mouse? If so, what message are we talking about here?
Or are you talking about some kind of wierd static class or something?


RedXVII

Nice i actually used the main window as the gap. That tutorial was ace. And works a trick! Its really nice.

As a side note, you know when you resize a window. How do you get it so that it doesnt flicker like crazy?


anon

We probably can not help you with the flicker problem without seeing some code.
If you have a fairly current version of masm32 installed, there is a splitter example.
Look in the \examples\EXAMPLE6\SPLITTER directory.

hutch--

Red,

Flicker is usually the result of multiple window repaints on multiple layered windows so for example if you have a control placed over a normal client area of a normal window, when you resize, both the client area of the main window and the control repaint the same area and on a large enough scale with many controls, the fast multiple repaints make the window flicker when its being resized.

With image data its easy enough to solve by using a back buffer and blitting the data onto the screen but with controls you are better to reduce the number of repaints so for example, if a control covers the entire client area of a window, you can simply set the background brush of the window to transparent so its not be repainted as the control already covers it.

This also works OK if for example you have two sub windows and a splitter bar as long as they cover all of the client area of the main window.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

RedXVII

Yes, the flicker is because the window seems to draw the back then the front. If i set it to transparrent, its perfect, except for the fact that the splitter bar is now transparent, and comes up very odd. So; Im going to have to make a very small class to put between the gap, right? This will also help if i have to make multiple bars.

Is there any way to actually make windows classes from scratch? or do you have to template them on others classes? (i'd probably use a static, i wonder if it sends a WM_NOTIFY on mouse click/moving)

Note: I did just try to use a static via superclassing it but for some bizarre reason, It makes the static class as a kindof, whole new window rather than inside my window. Dont know where i could have gone wrong. Im tired, nn.

hutch--

Red,

Just use the normal CreateWindowEx() specifying your own WNDCLASSEX structure to register the class for it. A splitter window is in fact very simple but the code to size the windows on either side of it is a bit fussy.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

RedXVII

#9
First time ive ever tried making my own class before so here goes...

mov wc.cbSize, SIZEOF WNDCLASSEX
mov wc.style, CS_PARENTDC or CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET HorizontalBarProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground, COLOR_BACKGROUND+1
mov wc.lpszMenuName, 0
mov wc.lpszClassName, OFFSET BarClass
mov wc.hIcon, 0
mov wc.hIconSm, 0
invoke LoadCursor, NULL, IDC_SIZENS
mov wc.hCursor, eax
invoke RegisterClassEx, addr wc


...on WM_CREATE

invoke CreateWindowEx, 0, addr BarClass, 0, WS_VISIBLE, 100, 100, 1, 1, hWnd, 0, hInstance, 0    ;Sizes do not matter, its about to be resized
mov hwndBar, eax


I thaught this would work, but alas; i am wrong. the CreateWindowEx returned 0, so i called GetLastError and it came up;

1447 -> ERROR_NO_SCROLLBARS
1447    The window does not have scroll bars.


Errrrm, im sonfused   :eek
Any ideas?

Edit: This is driving me up the wall. I just dont understand whats going wrong, pls pls help!!

RedXVII

hahaha! Got it!!! At last; after going a bit gun-ho with olly for 3 nights non stop, i found it. This ones wierd. The problem lies in my HorizontalBarProc. When createwindowex is called, it sends a WM_NCCREATE message to the proc. This has to return true, or the window creation WILL be canceled. DefWindowProc didnt seem to do this for me, i had to do it myself. Such a stupid little thing.

It now works perfectly as it should, and ive just made my first ever custom window class from scratch.  :dance:

Thanks anyway  :U


EDIT: After closer inspection DefWindowProc does indeed do it for you.... I think i must have made a really stupid mistake somewhere that i fixed without realising  :eek . Either that or something wierd is playing up.