Jump to content
Tuts 4 You

How to select all in edit control by mouse click on the outline?


LCF-AT

Recommended Posts

Posted

Hi Progman,

why GetSysColor?As I told before, the user did change the Edit control background color at WM_CTLCOLOREDIT message.I'll show you...

	invoke  GetSysColor,COLOR_INFOBK  ; tooltip color
	invoke  CreateSolidBrush,eax
	mov GSC, eax



	.elseif eax == WM_CTLCOLOREDIT
		invoke GetDlgCtrlID, lParam
		.if eax == IDC_EDIT
			invoke SetTextColor,wParam, Red
			invoke SetBkColor,wParam,rgb(255,255,225)
			mov eax,GSC
			ret
		.endif
		xor eax,eax
		ret

...now the question for me is how to find out the used color?How should GetSysColor work in that case if user did set a custom background color for that edit control?I thought I could find it out with the handle ID & RECT etc.In this example the color is yellowish / tooltip and excatly this color I need to use to create a frame in same color around the edit control.If I dont do that and just use basic white color then it looks like this....

RE_2021-06-27_205504.png.b8ac8c363b91eb95764038ebdb050f33.png

....you see, edit control background has user set custom color and I did use just white color to fill my class with + the gray FR.Now I would like to get the color the user has used for that edit control so that I can fill my class with same color so that it does match.Somehow I must read any pixel of the edit control rect inside to get the color.I dont see how GetSysColor should help me in that case.If yes then tell me how.

PS: I didn't check the source of XP yet.

greetz

Posted

Hi again,

I have another important question about RegisterClassEx & CreateWindowEx function.So I have created a class and point that to my custom Window procedere to handle all messages there if something does happens with my class etc.Now I would like to know how I can assign specific control handles into my Window procedere?In my example above I did create edit control = I have handle of it and this I can use on a static way to do something with it.But I dont wanna use a static method and to store every single control handle somewhere under .data? so I would like to assign specific control handle/s to my Window proc and to get it from there anyhow on any message.Do you know what I mean?

Example: Lets say the User has 5 Edit controls created and now I want to change all of them like I did (see pre post / Frame / select all).That means I get 5 diffrent Edit control handles I need to mod in my own Window proc but how to know / get the right edit control handle on message X to do something with it?Lets say on message WM_LBUTTONDOWN which gets triggered if I press on my class (frame around edit control) and at this message I need to get the edit control handle on that location.Maybe I could use WindowFromPoint function to get the handle of THAT edit control but this method seems not to be very smart and that why I am asking for whether there is any more simple method.Do you know any?

greetz

Posted

Hi kao,

ah thanks for the info again. :) I was playing around and I think I got it working now.

Video_2021-06-29_004121_merged.gif.efdf83f01c4ff5dea2a2e281f84ff7be.gif

User does just call my function with hWin / Edit handle and a syscolor or not. :)

greetz

Posted

Hi again,

I have a new question about used styles & Exstyles of a control.Also in this case I can use GetWIndowLong function but how to check it again?Its same problem like with ownerdraw I had few weeks ago.How to check for specific style flags and remove or add them?

Example:

CONTROL "",IDC_EDIT,"Edit",0x5eb00001,10,10,200,8,0x00000000
------------------------------
0x5eb00001 <-- StyleFlags
               
WS_CHILD                             equ 40000000h
WS_VISIBLE                           equ 10000000h              
WS_DISABLED                          equ 8000000h
WS_CLIPSIBLINGS                      equ 4000000h
WS_CLIPCHILDREN                      equ 2000000h
WS_BORDER                            equ 800000h
WS_VSCROLL                           equ 200000h
WS_HSCROLL                           equ 100000h
ES_CENTER                            equ 1h               

Now on calling GetWindowLong with GWL_STYLE on that control I get the value of 5E300001 back.Not sure why its diffrent.

1.) How to check whether specific flags are already used like WS_VISIBLE?

2.) How to remove specific flags from a STYLE result value?Lets say I just wanna remove WS_VISIBLE flag straight.How to do that?I know I can use thr "or" command to add flags just if I know that a XY flag isnt used yet but also here I have to check first = question 1.

5E300001 in eax
--------------------------
	mov eax, 5E300001h
	push eax     ; backup style
	xor ecx, ecx ; value to add
	and eax, ES_CENTER
	.if eax
		; ES_CENTER used
		; How to disable it now?
		; using sub ES_CENTER?
		mov ecx, ES_CENTER
	.endif
	pop eax 	 ; restore original style
	sub eax, ecx ; sub ES_CENTER from style

Doing like this?

greetz

Teddy Rogers
Posted
15 hours ago, LCF-AT said:

1.) How to check whether specific flags are already used like WS_VISIBLE?

There are a few slightly different methods to do this, one is like this...

GetWindowInfo_(hWnd, @pwi)

If pwi\dwStyle & #WS_VISIBLE
 ; Window has WS_VISIBLE
EndIf

 

15 hours ago, LCF-AT said:

2.) How to remove specific flags from a STYLE result value?

You could do it something like this...

; Remove only WS_VISIBLE from the window whilst keeping its other styles. 

SetWindowLongPtr_(hWnd, #GWL_STYLE, GetWindowLongPtr_(hWnd, #GWL_STYLE) & ~#WS_VISIBLE)

If you only want to change WS_VISIBLE use SetWindowPos.

Also make sure you only use SetWindowLongPtr and GetWindowLongPtr as per the API notes explain...

Ted.

  • Like 1
Posted

Hi Ted,

thanks for the info about that function but it makes no diffrent to SetWindowLong WL_STYLE.I get same result value back in your GetWIndowInfo function dwStyle.I also can have those Ptr functions and just can use normal Get/SetWindowLong functions.So my goal was it just to calc (check/add/remove) style flags from a entire handle.So if I see it right now then I can use the TEST command to check for any flag whether its present or not.For adding a flag I have to use the OR command and to remove a flag I have to use the XOR command....right?So on my tests it seems to work so using TEST / OR / XOR for that.

But now I have a strange new problem about using controls from resouces and setting them up to enable / disable diffrent flags.Here is something going wrong for me using WInASM.

Example: I have created a EDIT control in WInASM resources window and now I just enable the flag WS_VISIBLE

WS_VISIBLE                           equ 10000000h

and compile the test executable.Now if I check the GWL_STYLE handle of that Edit control then I get a value of 50000000 in eax  back instead of 10000000!In this case the WS_CHILD flag was added but I dont have it enabled.....so why is this happen here?

Example2: I have enabled WS_VISIBLE and can check for that style like this if I have in eax the entire style handle....

.if eax & WS_VISIBLE
	; found
	xor eax, WS_VISIBLE ; let remove it
.else
	; not into
	or eax, WS_VISIBLE  ; lets add it
.endif

....and now I wanna remove it if found or add it if not found.Seems to work too.

Example3: Now I found another problem about flags.In my Edit control I have enabled the flag WS_BORDER which has a value of...

WS_BORDER                            equ 800000h

....and I have added WS_VISIABLE...and WS_CHILD...

WS_CHILD                             equ 40000000h
WS_VISIBLE                           equ 10000000h
WS_BORDER                            equ 800000h

....in the sum its a value of 50800000h.Now if I check this in Olly calling again GetWindowLong GWL_STYLE I get a value of 50000000 in eax back what means WS_CHILD & WS_VISIBLE flag are into but where is the WS_BORDER flag?The Border is to see in the edit control but I dont get the flag for this back.I also tried using WinSpy tool to check the style flags and there I also dont get the WS_BORDER flag to see!=?In both cases WinSpy does show me the same value of 50000000.Thats strange!But it also shows difftent values for ExStyle even if I have both ExStyles set to 0 in both Edit controls...!=?See my image...

ER_2021-06-30_223759.png.c5a415838561341681d4ca0e428bed23.png

....now the edit control below without border...

ER2_2021-06-30_223957.png.6fe3cbec66c5d28295b3daae8a3d33b6.png

....do you see?Both have same sytle values with or without border and also diffrent ExStyle values even if I dont use ExStyle?

	CONTROL "",IDC_EDIT,"Edit",0x50800000,10,10,200,8,0x00000000
	CONTROL "",IDC_EDIT1004,"Edit",0x10000000,10,25,200,8,0x00000000

Thats really bad.So in this case I can not check for WS_BORDER.Had anyone a clue what is wrong here?

greetz

Posted

Hi again,

found some things out.When I use WinASM resource window to create a Edit control with WS_BORDER then I dont get WS_BRODER flag using GetWindowLong function as I told above.Also WinSpy dosent get any WS_BORDER because its NOT used and instead that this WS_EX_CLIENTEDGE is used.Thats strange right.Somehow WinASM / MASM dosent compile it as I did setup.

Now I was playing around creating Edit control by using CreateWIndowEx function and here I get some similar strange issues.Below the code line....

invoke CreateWindowEx,0,chr$("Edit"),NULL,WS_CHILD or WS_VISIBLE or WS_BORDER ,10,10,100,20,hWin,0,hInstance,0

...WinSpy shows me the value of 50000000 in GWSTYLE = WS_CHILD and WS_VISIBLE and no WS_BORDER  value = WTF?

Next try......by addine ExStyle WS_EX_CLIENTEDGE

invoke CreateWindowEx,WS_EX_CLIENTEDGE,chr$("Edit"),NULL,WS_CHILD or WS_VISIBLE or WS_BORDER ,10,10,100,20,hWin,0,hInstance,0

....now WinSpy does show me everything!=?Value of 50800000 in GWSTYLE and value 00000200 for ExStyles.All is there in this case!=?I also see 2 borders now.So whats the damn problem here?Why I dont get that FUPing WS_BORDER value?Is it some WIndows bug or secret special whatever?Am I again toooo un-smart for that part to understand it?Maybe anyone of you could help a little to bring some light into that stuff.Otherwise I'am going out of clues now.Nobody else had some similar problems before?

greetz

Posted

Hi guys,

did anyone test it out?Trying to create a Edit control with WS_BORDER style (nothing into ExStyle) and checking that control with tools like WinSpy etc to see that the WS_BORDER style isnt shown?Thats really strange guys.

Example: Create Edit control only with WS_CHILD WS_VISIBLE & WS_BORDER

invoke CreateWindowEx,0,chr$("Edit"),NULL,WS_CHILD or WS_VISIBLE or WS_BORDER ,10,10,100,20,hWin,0,hInstance,0

...now watch my gif animation trying to play with WinSpy where I can enable WS_BORDER another time and to get another Border to see + enable WS_EX_CLIENTEDGE to get another Border = 3 border looks.

BorderP.gif.e414862a59731a67c86e0fbf348c6a42.gif

Do you see?Can anyone of you explain that what it is and how to get that Border removed I did created by using WS_BORDER style in CreateWindowEx function?Can anyone confirm the same problem?

greetz

Posted

Not all controls will use all of the window styles, or some of them might use them differently or ignore them. The edit control creates its own frame instead of using the WS_BORDER style, probably due to window theme and the ability to change the frame color to indicate the current focus or lost focus status.

  • Like 1
Posted

Hi fearless,

sounds bad.Is it only for WS_BORDER or also another style / ExStyle flags too?If I create a Edit control with WS_BORDER style then I can not checking for it and also not disable it if its used.Somehow that sounds not very common or are there any special De-tours I can go?

- How to disable enabled WS_BORDER style from Edit control?

Answer: Not possible or...?

AddOn Question: So lets say I can not check for WS_BORDER style and others etc.....is it then possible to create a own Edit control to place it onto same place of old Edit control and to change the handle anyhow?

Example: Edit control by user / handle 1122 /.Now I get that handle to modify that Edit control but I can not check for all style and just create another Edit control with my styles and place it onto place of Edit control from user and that original Edit control I hide / destroy.Is there a way to repleace that Edit control handle 1122 with my handle 3344?I dont think so or?

greetz

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...