Jump to content
Tuts 4 You
Sign in to follow this  
LCF-AT

How to control CMD console?

Recommended Posts

ragdog

Visual mode has Radasm but no text mode function official


 


For the Reseditor click on the project explorer pane on your resource file (.rc)


Share this post


Link to post
mrexodia

You can try ResEdit. Watch out for the ads though...

Share this post


Link to post
ragdog

Radasm has a Reseditor

Share this post


Link to post
LCF-AT

Hi again,


 


new short question: If I create any dialog with some new stuff into (buttons static etc) then I see if I change the size of Dialog (with mouse or press max button) that now all content inside keeps at the same position.So it does not move with the main dialog.The question now I have is,is that always so or is there any quick setting in the resources (Style or ExStyle) where I can enable something so that all buttons for exsample do move with the main dialog if this does change the size to below for example etc.


 


A friend told me already to use MoveWindow API what also works with my exsample Listview and the question now also is whether I have to do this with ALL added buttons / statics whatever?If yes = WHY! :) Below what I have for this.First MoveWindow is for my listview what does work now to have it in a special area and the second I wanna use for the button I have set left-below but there I got some trouble and which I not get working on same way etc you know.



.elseif uMsg==WM_SIZE invoke GetClientRect,hWnd,addr rect
mov eax,rect.bottom
sub eax,rect.top
sub eax, 40h
mov ht,eax
mov eax, rect.right
sub eax, 80h
mov edi, eax
invoke MoveWindow,hListView,10h,10h,eax,ht,TRUE invoke GetDlgItem,hWnd,1002 ; <-- my button
mov esi,eax
invoke MoveWindow,esi,10h,10h,60h,ht,TRUE

So is there no easier way to handle this size / position moving with Dialog etc?Lets say I have later 100 items on my dialog and then I need to write this code 100 times to just for the pos-move?I think not or?Would be cool if you could help again with some infos.


 


Thank you


Share this post


Link to post
simple

you have to set your window min/max size, then write a 1 brief algorhythm to loop through all your child hWnd's. dont handle 100 items individually because it'll be slow/resource intense


 


heres a sample -  when u change the window size of the crackme (dragging w/mouse, min/max button, etc), everything inside changes in < 40 C lines. u can also use the WindowSize function alone to set a static size value so size cannot be changed.



.elseif uMsg == WM_SIZE
; call this to set window minimum and maximum size
; for window that cannot be resized arg1 == arg3 & arg2 == arg4
invoke WindowSize, hWnd, 305, 305, 265, 190 ; function to loop through all child hWnd's and set border in relation
; to window size
invoke WidgetResize, hWnd .elseif uMsg == WM_CREATE
invoke CreateWindowEx, NULL, addr ListBox, NULL, WS_VISIBLE or WS_CHILD or WS_BORDER, 10, 120, 230, 20, hWnd, 5, NULL, NULL
invoke CreateWindowEx, NULL, addr Edit, addr NameHere, WS_VISIBLE or WS_CHILD or WS_BORDER, 10, 10, 230, 20, hWnd, 4, NULL, NULL
invoke CreateWindowEx, NULL, addr Edit, addr SerialHere, WS_VISIBLE or WS_CHILD or WS_BORDER, 10, 35, 230, 20, hWnd, 2, NULL, NULL
invoke CreateWindowEx, NULL, addr Button, addr Register, WS_VISIBLE or WS_CHILD or WS_BORDER, 75, 60, 90, 20, hWnd, 1, NULL, NULL
invoke CreateWindowEx, NULL, addr Static, addr Caption, WS_VISIBLE or WS_CHILD or WS_BORDER, 10, 90, 230, 20, hWnd, 3, NULL, NULL

heres the function sources



; Desc - Sets parent window min/max size or static size
; Args - Max/MinWidth & Max/MinHeight in x/y format
; Ret - none
;void WindowSize(HWND hWnd, int MaxWidth, int MaxHeight, int MinWidth, int MinHeight)
;{
; RECT cord;
; int x, y;
; GetWindowRect(hWnd, &cord);
; x = cord.right - cord.left;
; y = cord.bottom - cord.top;
; MapWindowPoints(HWND_DESKTOP, GetParent(hWnd), (LPPOINT)&cord, 2);
; if (x > MaxWidth || y > MaxHeight)
; MoveWindow(hWnd, cord.left, cord.top, MaxWidth, MaxHeight, TRUE);
; if (x < MinWidth || y < MinHeight)
; MoveWindow(hWnd, cord.left, cord.top, MinWidth, MinHeight, TRUE);
;
;}
WindowSize proc hWnd:DWORD, MaxWidth:DWORD, MaxHeight:DWORD, MinWidth:DWORD, MinHeight:DWORD
local Cord:RECT
invoke GetWindowRect, hWnd, addr Cord
invoke GetParent, hWnd
mov edx, eax
invoke MapWindowPoints, HWND_DESKTOP, edx, addr Cord, 2
mov eax, Cord.right
sub eax, Cord.left
mov ecx, Cord.bottom
sub ecx, Cord.top
cmp eax, MaxWidth
jg m0vem@x
cmp ecx, MaxHeight
jg m0vem@x
cmp eax, MinWidth
jl m0vem1n
cmp ecx, MinHeight
jl m0vem1n
jmp gtf0
m0vem@x:
invoke MoveWindow, hWnd, Cord.left, Cord.top, MaxWidth, MaxHeight, 1
;invoke ShowWindow, hWnd, SW_SHOW ; msdn says its necessary, but its optional
jmp gtf0
m0vem1n:
invoke MoveWindow, hWnd, Cord.left, Cord.top, MinWidth, MinHeight, 1
;invoke ShowWindow, hWnd, SW_SHOW
gtf0:
xor eax, eax
xor ecx, ecx
ret
WindowSize endp ; Desc - 1 function to auto resize all widgets in a WndProc
; Args - Parent hWnd
; Ret - void
;void WidgetResize(HWND hWnd)
;{
; HWND Label;
; RECT Parent, Child;
; POINT Orig;
; int pX, pY, cX, cY, i;
; GetWindowRect(hWnd, &Parent);
; pX = Parent.right - Parent.left;
; pY = Parent.bottom - Parent.top;
; for (i = 5; i > 1; i--)
; {
; Label = GetDlgItem(hWnd, i);
; GetWindowRect(Label, &Child);
; cX = Child.right - Child.left;
; cY = Child.bottom - Child.top;
; Orig.x = Child.left;
; Orig.y = Child.top;
; ScreenToClient(hWnd, &Orig);
; if (pX - cX != 45)
; cX = pX - 45;
; if (i == 5)
; {
; if (pY - cY != 172)
; cY = pY - 172;
; }
; MoveWindow(Label, Orig.x, Orig.y, cX, cY, TRUE);
; }
;}
WidgetResize Proc hWnd:HWND
local Parent:RECT
local Child:RECT
local Orig:POINT
local Counter:DWORD
local pX, pY, chX, chY:DWORD
local hwnd:HWND
invoke GetWindowRect, hWnd, addr Parent
mov eax, Parent.right
sub eax, Parent.left
mov pX, eax
mov eax, Parent.bottom
sub eax, Parent.top
mov pY, eax
mov Counter, 5
.while (Counter > 1)
invoke GetDlgItem, hWnd, Counter
mov hwnd, eax
invoke GetWindowRect, hwnd, addr Child
mov eax, Child.right
sub eax, Child.left
mov chX, eax
mov eax, Child.bottom
sub eax, Child.top
mov chY, eax
push Child.left
pop Orig.x
push Child.top
pop Orig.y
invoke ScreenToClient, hWnd, addr Orig
mov eax, pX
sub eax, chX
cmp eax, 16h ; condition for right window border
je ch3ckY
xor eax, eax
mov eax, pX
sub eax, 16h
mov chX, eax
ch3ckY:
.if (Counter == 5) ; since no other objects have Y border
mov eax, pY ; only necessary for single widget w/Y border
sub eax, chY ; this code needs to run on all hWnd's
cmp eax, 172d ; w/bottom side border
je n0ch@nge
xor eax, eax
mov eax, pY
sub eax, 172d
mov chY, eax
.endif
n0ch@nge:
invoke MoveWindow, hwnd, Orig.x, Orig.y, chX, chY, 1
dec Counter
.endw
xor eax, eax
ret
WidgetResize endp

MasmCrackme.rar

  • Like 1

Share this post


Link to post
LCF-AT

Hi simple and thanks for your example code & file so I will read and check this.So you know I try to use resources to build a GUI instead of using CreateWindow API (its easier & better for me as newbie).The main problem in that case seems to be that if I create any sample GUI with all stuffs (labels / static / listview / buttons etc) that this makes not much sense to set them on any place where I want if I later need to use the MoveWindow API where I also need to use again  X,Y,hight,wight parameters so this really sucks.No idea why there is no setting options in styles to set this stuff "fix to ratio to Dialog" on that or something you know what I mean.Anyway,so at the moment I can just use MoveWindow API with values xy + checking whether static / buttons & co are exactly on that position where I did set them into resources too.Thats totaly OMG! :) So now I use this....



.elseif uMsg==WM_SIZE invoke GetClientRect,hWnd,addr rect
mov eax,rect.bottom
sub eax,rect.top
sub eax, 40h
mov ht,eax
mov eax, rect.right
sub eax, 80h
invoke MoveWindow,hListView,10h,10h,eax,ht,TRUE invoke GetDlgItem,hWnd,1002
mov esi,eax
add ht, 18h
invoke MoveWindow,esi,10h,ht,60h,15h,TRUE
invoke GetDlgItem,hWnd,1003
mov esi,eax
invoke MoveWindow,esi,70h,ht,60h,15h,TRUE

...below 2 buttons.


 


greetz


Share this post


Link to post
Alzri2

you can also write a loop to move them all without repeating the code :)


Share this post


Link to post
LCF-AT

Hi again,


 


another question to my listview box.I got it working now so far but now I wanna add a function to select a simple entry (line) and I wanna move it up or down to change the position.



11111
22222
33333
44444
55555 If I select line 3 (33333) then I wanna move it now to
any other line higher or below... 11111
22222
44444
55555
33333

So how can I do this?Also a function to do this directly with the mouse (select line X keep left mouse pressed + move up or down) would be better but also here I have no ideas how to do this.Maybe you know it again and can help me too with some infos.


 


Thank you


Share this post


Link to post
simple

First make yourself a menu



.elseif uMsg == WM_CONTEXTMENU
invoke GetDlgItem, hWnd, 1002
mov ListHwnd, eax
cmp eax, dword ptr ss:[wParam]
jne f1nish
invoke CreatePopupMenu
mov hMenu, eax
invoke InsertMenu, hMenu, 0, MF_BYCOMMAND or MF_STRING or MF_ENABLED, 11, SADD("Add")
invoke InsertMenu, hMenu, 0, MF_BYCOMMAND or MF_STRING or MF_ENABLED, 10, SADD("Edit")
invoke InsertMenu, hMenu, 0, MF_BYCOMMAND or MF_STRING or MF_ENABLED, 11, SADD("Delete")
invoke InsertMenu, hMenu, 0, MF_BYCOMMAND or MF_STRING or MF_ENABLED, 12, SADD("Move Up")
invoke InsertMenu, hMenu, 0, MF_BYCOMMAND or MF_STRING or MF_ENABLED, 13, SADD("Move Down")
mov eax, lParam
shr eax, 16
;cwde
mov YParam, eax
xor eax, eax
mov eax, lParam
cwde
mov XParam, eax
invoke TrackPopupMenu, hMenu, TPM_TOPALIGN or TPM_LEFTALIGN, XParam, YParam, 0, hWnd, NULL

Heres code for delete, move up, move down. in all u loop through all items, see if its the selected one. when moving get the current text, then delete it and replace it @ index +1 or -1. this is just to show the concept, you still need to add code to make sure first can't move up and last index cant move down



.elseif uMsg==WM_COMMAND .elseif wParam == 10
; delete currently selected item .elseif wParam == 11
invoke GetDlgItem, hWnd, 1002
mov ListHwnd, eax
invoke SendMessage, ListHwnd, LVM_GETITEMCOUNT, 0, 0
mov Total, eax
mov ebx, 0
.while (Total > ebx) ; ecx is occupied w/retval of SendMessage invoke SendMessage, ListHwnd, LVM_GETITEMSTATE, ebx, LVIS_SELECTED
.if (eax > 0)
invoke SendMessage,ListHwnd, LVM_DELETEITEM, ebx, 0
.endif
inc ebx
.endw ; move down
.elseif wParam == 13 invoke GetDlgItem, hWnd, 1002
mov ListHwnd, eax
invoke SendMessage, ListHwnd, LVM_GETITEMCOUNT, 0, 0
mov Total, eax
mov ebx, 0
.while (Total > ebx) ; ecx is occupied w/retval of SendMessage invoke SendMessage, ListHwnd, LVM_GETITEMSTATE, ebx, LVIS_SELECTED
.if (eax > 0)
mov lvi.iSubItem, 0
mov lvi.cchTextMax, 55h
m2m lvi.pszText, offset SubItem0
invoke SendMessage, ListHwnd, LVM_GETITEMTEXT, ebx, addr lvi mov lvi.iSubItem, 1
m2m lvi.pszText, offset SubItem1
invoke SendMessage, ListHwnd, LVM_GETITEMTEXT, ebx, addr lvi mov lvi.iSubItem, 2
m2m lvi.pszText, offset SubItem2
invoke SendMessage, ListHwnd, LVM_GETITEMTEXT, ebx, addr lvi invoke SendMessage,ListHwnd, LVM_DELETEITEM, ebx, 0 inc ebx
mov lvi.iItem,ebx
mov lvi.imask,LVIF_TEXT
mov lvi.iSubItem,0
m2m lvi.pszText,offset SubItem0
invoke SendMessage, hListView,LVM_INSERTITEM, 0,addr lvi
mov lvi.iSubItem,1
m2m lvi.pszText,offset SubItem1
invoke SendMessage, hListView,LVM_SETITEM, 0,addr lvi
mov lvi.iSubItem,2
m2m lvi.pszText,offset SubItem2
invoke SendMessage, hListView,LVM_SETITEM, 0,addr lvi
.endif
inc ebx
.endw
; move up
.elseif wParam == 12
invoke GetDlgItem, hWnd, 1002
mov ListHwnd, eax
invoke SendMessage, ListHwnd, LVM_GETITEMCOUNT, 0, 0
mov Total, eax
mov ebx, 0
.while (Total > ebx) ; ecx is occupied w/retval of SendMessage invoke SendMessage, ListHwnd, LVM_GETITEMSTATE, ebx, LVIS_SELECTED
.if (eax > 0)
mov lvi.iSubItem, 0
mov lvi.cchTextMax, 55h
m2m lvi.pszText, offset SubItem0
invoke SendMessage, ListHwnd, LVM_GETITEMTEXT, ebx, addr lvi mov lvi.iSubItem, 1
m2m lvi.pszText, offset SubItem1
invoke SendMessage, ListHwnd, LVM_GETITEMTEXT, ebx, addr lvi mov lvi.iSubItem, 2
m2m lvi.pszText, offset SubItem2
invoke SendMessage, ListHwnd, LVM_GETITEMTEXT, ebx, addr lvi invoke SendMessage,ListHwnd, LVM_DELETEITEM, ebx, 0 dec ebx
mov lvi.iItem,ebx
mov lvi.imask,LVIF_TEXT
mov lvi.iSubItem,0
m2m lvi.pszText,offset SubItem0
invoke SendMessage, hListView,LVM_INSERTITEM, 0,addr lvi
mov lvi.iSubItem,1
m2m lvi.pszText,offset SubItem1
invoke SendMessage, hListView,LVM_SETITEM, 0,addr lvi
mov lvi.iSubItem,2
m2m lvi.pszText,offset SubItem2
invoke SendMessage, hListView,LVM_SETITEM, 0,addr lvi
.endif
inc ebx
.endw
.endif

ill start working on a masm sample to show how to do it dragging w/mouse


Share this post


Link to post
LCF-AT

Hi simple,


 


thanks so far but as I see you haven't check my latest source.


 


The problem now I got is that I don't want to change the first No. row so this should keep same only the last 2 rows should change.Now I tried to adjust this but I don't get it work if I remove the entrys...



mov lvi.iSubItem,0
m2m lvi.pszText, offset SubItem0
invoke SendMessage, hListView,LVM_INSERTITEM, 0,addr lvi

...if I just use iSubItem 1 & 2 then its not working correctly so it seems I can't just enter something in any single row without to use the first right?Damn!


 


Next problem is the up & down moving part so I always have to reselect the line after one move so it should keep selected if I press move up or down you know?


 


greetz


Share this post


Link to post
simple

i answered the question asked ; ) this function should do what u want, works for me. keep the original code the same and call it after you add the new items


 


to do row highlighting do SendMessage(LVS_EX_FULLROWSELECT). also attached a C binary of drag/drop listview. its a lot of C, no time to finish translating to masm atm (about half way) maybe itll help u



; Desc: Gets total # of rows, sets numerical value
; of 1st item startin w/1, ending w/last row
; args: hwnd to listview child widget
; retval: none
;void ResetFirst(HWND Handle)
;{
; LVITEM lvi;
; int Item = SendMessage(Handle,LVM_GETITEMCOUNT,0,0);
; char SubItem0[15];
; for (int i = 0; i < Item; i++)
; {
; sprintf(SubItem0, "%d", i + 1);
; lvi.iItem = i;
; lvi.mask = LVIF_TEXT;
; lvi.iSubItem = 0;
; lvi.pszText = SubItem0;
; SendMessage(Handle,LVM_SETITEM,0,(LPARAM)&lvi);
; }
;}
ResetFirstItem proc Handle:HWND
local lvi:LVITEM
local TotalItems:DWORD
invoke SendMessage, Handle, LVM_GETITEMCOUNT, 0, 0
mov TotalItems, eax
mov lvi.imask, LVIF_TEXT
mov lvi.iSubItem, 0
mov ebx, 0
.while ebx != TotalItems
add ebx, 1
invoke wsprintf, addr SubItem0, addr Format, ebx
sub ebx, 1
mov lvi.iItem, ebx
m2m lvi.pszText,offset SubItem0
invoke SendMessage, Handle, LVM_SETITEM, 0, addr lvi
inc ebx
.endw
xor eax, eax
xor ebx, ebx
leave
retn
ResetFirstItem endp

call it like this



invoke GetDlgItem, hWnd, 1002 ; or whatever ur resource id is invoke ResetFirstItem, eax

edit - binary is just proof of concept, there are crashes from unhandled messages that error checking will fix. in the masm code globals are Format db "%d", 0 SubItem0 db 256 dup (?)

Rumble.rar

Edited by simple (see edit history)
  • Like 1

Share this post


Link to post
LCF-AT

Hi again,


 


today I found a drag & Drop example of a TreeView and tried to translate it for a Listview but also without success. :( Really not so easy with all the tons of structs and commands.Just wanna ask whether there are any Listview Drag & Drop m32lib's?So I found many of them in this folder which working like APIs (very nice) so maybe there are also such libs created by any people which I don't know and have so if you know then tell me or maybe you can build such a lib etc. :) Would be nice again.


 


greetz


Share this post


Link to post
LCF-AT

Hi again,


 


does nobody code with ASM?


 


Have a another more simple question / request.As I said I have a listview created with COLUMNs etc and if I now select any line to move it up or down via button press then the selection is gone right after button press and now I wanna know how I can re-select the line again automaticly in my code.I tried already the LVM_SETITEMSTATE paramter but does not work so can anybody tell me what to use?


 


Thanks


Share this post


Link to post
simple

Works fine for me. Try this -



;void SetItemHighlight(HWND Handle, int ItemNumber)
;{
; LVITEM lvi1;
; lvi1.state = LVIS_FOCUSED | LVIS_SELECTED;
; lvi1.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
; lvi1.mask = LVIF_STATE;
; SendMessage(Handle, LVM_SETITEMSTATE, ItemNumber, (LPARAM)&lvi1);
;}
SetItemHighlight proc Handle:HWND, ItemNumber:DWORD
local lv:LVITEM
mov lv.state, LVIS_FOCUSED or LVIS_SELECTED
mov lv.stateMask, LVIS_FOCUSED or LVIS_SELECTED
mov lv.imask, LVIF_STATE
invoke SendMessage, Handle, LVM_SETITEMSTATE, ItemNumber, addr lv
leave
retn
SetItemHighlight endp

Then call it inside your move button function like this -



; move down
.elseif wParam == 13 invoke GetDlgItem, hWnd, 1002
mov ListHwnd, eax
invoke SendMessage, ListHwnd, LVM_GETITEMCOUNT, 0, 0
mov Total, eax
mov ebx, 0
.while (Total > ebx) ; ecx is occupied w/retval of SendMessage
invoke SendMessage, ListHwnd, LVM_GETITEMSTATE, ebx, LVIS_SELECTED
.if (eax > 0)
...
...
... invoke SendMessage, hListView,LVM_SETITEM, 0,addr lvi invoke SetItemHighlight, hListView, ebx .endif
inc ebx
.endw

can somebody build u a lib? they already did, its called Qt : ). I use it on all my projects, masm too. Qt looks beautiful man and is easy, its great for artsy stuff. winapi is involved and it looks like sh!t, like seomthing on a supermarket cash register in the 90's u know.


Share this post


Link to post
LCF-AT

Hi and thanks so far now it works with some changes.Not really sure why it works now but it works. :) Not easy to understand all this stuff.Ok now I can move up / down as I wanted but is it also possible to set also the marked selection as I can do with the mouse?If I select any line with mouse then it gets marked (you know what I mean) so is this also possible to set?At the moment its more like a hidden selection.


 


One thing: How can I setup the button I press (up / down) to any kind of rapid fire?Lets say I wanna move 100 lines below then I need to press 100 times so what to do to keep the button pressed for one or two seconds and then it should start the rapid action till I no more keep pressed down this button.Is this also possible with the button?


 


greetz


Share this post


Link to post
simple

I dont understand what u mean "set also the marked selection as I can do w/mouse?"  W/that function you can set whatever item u want highlighted by changing the 2nd argument to whatever # item u want


 


For ur 2nd question, w/default properties of listview you can use keypad up or keypad down to change highlighted item, and u can also hold it down and it will "autoscroll" or rapidfire. 


 


to do it w/mouse button put a call to GetKeyState(VK_LBUTTON) & 100 in ur button press code, that'll tell u if it's held down. another way is using WM_LBUTTONDOWN/WM_LBUTTONUP messages


 


a few suggestions... in C stuff like this is normally done w/ListView_ macros, which RagDog has translated and posted on masm forums so maybe that might make it more readable. check out theforgers winapi tuts too, it goes over a lot of this


Share this post


Link to post
ragdog

 

a few suggestions... in C stuff like this is normally done w/ListView_ macros, which RagDog has translated and posted on masm forums so maybe that might make it more readable. check out theforgers winapi tuts too, it goes over a lot of this

I have this not translated

But is only a small snippet what i have posted.

 

 

What Lcf want is drag/drop the items

you must handle WM_Notify >> LVN_BEGINDRAG set ImageList drag image

then must u handle WM_MOUSEMOVE and WM_LBUTTONUP

 

Now must you get the current items and set to the new items etc....

 

It give enough C/Cpp examples must only translate it to Masm

 

Cheers,

Edited by ragdog (see edit history)

Share this post


Link to post
simple

Yeah I know all that is already in the last C binary I posted (no time to do it masm atm), but those macros will be easier to understand than the SendMessage calls imo


Share this post


Link to post
ragdog

 

but those macros will be easier to understand than the SendMessage calls imo

 

Easier? ok your view, but i use in  sources without macros.

What lcf need is the basics and must read bei Msdn to learn it.

Edited by ragdog (see edit history)

Share this post


Link to post
LCF-AT

Hi again,


 


I tried WM_LBUTTONDOWN but its only working if I press the left mouse button directly on the client area = where nothing is.If I press the up / down button then it doesen't work.Is there no normaly keyboard function something like shift+UP / Down to select the line/s and move them?Hmmmm!


 


Yes I tried already to handle the drag & drop stuff but I don't get it working of course (as always).I found a exsample code for drag & drop for a TreeView but can't adjust it to LView. :( Why I have to use a image on LV too?


 


Jetzt komm mal aus der Hüfte Burli und lass wat anständiges an Codes rüberwachsen sonst sitz ich noch bis Ostern an der Jauche!Hopp hopp... :)


 


greetz


Share this post


Link to post
ragdog

You can ask for a drag/drop listview at the Masm32 board and you have it before easter´n :prop:


 


I have not many Zeit at the moment.


Edited by ragdog (see edit history)

Share this post


Link to post
sama

Maybe sometimes it's hard for one's own Ego, to ask questions in your native language.

I'm sure if you would do it, there would

be the possibility to understand what someone tries to tell you, at 100% !!

Edited by sama (see edit history)

Share this post


Link to post
Teddy Rogers

I tried WM_LBUTTONDOWN

 

How about using GetAsyncKeyState with VK_LBUTTON? Nice and easy example in PureBasic, you don't need to have window focus to activate VK events...

If OpenWindow(1, #Null, #Null, #Null, #Null, "An invisible window doing invisible things...", #PB_Window_Invisible)

 

  Repeat

    MyEvent = WaitWindowEvent(10)

    

    If GetAsyncKeyState_(#VK_LBUTTON) & $8000

      Debug "You pressed left button down!"

    EndIf

    

    If GetAsyncKeyState_(#VK_ESCAPE) & $8000

      MyEvent = #PB_Event_CloseWindow

    EndIf

  Until MyEvent = #PB_Event_CloseWindow    

EndIf

Ted.

Share this post


Link to post
simple

heres a sample listview drag/drop. didnt take as long as i thought. had to change several things from those dreamincode/codeproject articles.achtung lcf, u can play w/iRetv & NewPos value (do inc and dec) for exact placement location on the listview, if u want add features

	.elseif uMsg==WM_NOTIFY		push edi		mov edi,lParam		assume edi:ptr NMHDR		mov eax,[edi].hwndFrom		.if eax 			.if [edi].code == LVN_BEGINDRAG				mov bFirst, 1 ; 				mov p.x, 8				mov p.y, 8				invoke SendMessage, ListHwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED				mov Position, eax				.while Position != -1				    .if bFirst == 1					        invoke SendMessage, ListHwnd, LVM_CREATEDRAGIMAGE, Position, addr p  					        mov hDragImageList, eax					        invoke ImageList_GetImageInfo, hDragImageList, 0, addr imf					        mov eax, imf.rcImage.bottom						mov iHeight, eax						mov bFirst, 0                                    .elseif bFirst != 1					        invoke SendMessage, ListHwnd, LVM_CREATEDRAGIMAGE, Position, addr p  						mov hOneImageList, eax						invoke ImageList_Merge, hDragImageList, 0, hOneImageList, 0, 0, iHeight						invoke ImageList_Destroy, hDragImageList                                                invoke ImageList_Destroy, hOneImageList						mov eax, hTempImageList						mov hDragImageList, eax 						invoke ImageList_GetImageInfo, hDragImageList, 0, addr imf					        mov eax, imf.rcImage.bottom						mov iHeight, eax                                    .endif									    invoke SendMessage, ListHwnd, LVM_GETNEXTITEM, Position, LVNI_SELECTED				    mov Position, eax				.endw				invoke ImageList_BeginDrag, hDragImageList, 0, 0, 0				mov eax, dword ptr ss:[ebp+14h]				add eax, 20h				MOV EDX,DWORD PTR DS:[EAX+4]				MOV eax,DWORD PTR DS:[EAX]				mov pt.y, edx				mov pt.x, eax				invoke ClientToScreen, ListHwnd, addr pt				invoke GetDesktopWindow					invoke ImageList_DragEnter, eax, pt.x, pt.y				mov bDragging, 1				invoke SetCapture, hWnd		    .endif		.endif	        .elseif uMsg == WM_MOUSEMOVE	        .if bDragging == 0		    jmp th3nd		.endif		mov eax, lParam		movzx eax, ax		mov p.x, eax		mov eax, lParam		shr eax, 10h		movzx eax, ax		mov p.y, eax 		invoke ClientToScreen, hWnd, addr p		invoke ImageList_DragMove, p.x, p.yth3nd:    .elseif uMsg == WM_LBUTTONUP		mov bDragging, 0                invoke ImageList_DragLeave, ListHwnd		invoke ImageList_EndDrag		invoke ImageList_Destroy, hDragImageList		invoke ReleaseCapture		mov eax, lParam		movzx eax, ax		mov lvhti.pt.x, eax		mov eax, lParam		shr eax, 10h		movzx eax, ax		mov lvhti.pt.y, eax 		invoke ClientToScreen, hWnd, addr lvhti.pt		invoke ScreenToClient, ListHwnd, addr lvhti.pt                invoke SendMessage, ListHwnd, LVM_HITTEST, 0, addr lvhti		.if lvhti.iItem == -1		    jmp the3nd		.endif		mov eax, lvhti.flags		and eax, LVHT_ONITEMLABEL		.if eax == 0		    jmp the3nd		.endif		mov eax, lvhti.flags		and eax, LVHT_ONITEMSTATEICON		.if eax == 0		    jmp the3nd		.endif		mov eax, lvhti.iItem		mov lvi2.iItem, eax		mov lvi2.iSubItem, 0		mov lvi2.imask, LVIF_STATE		mov lvi2.stateMask, LVIS_SELECTED		invoke SendMessage, ListHwnd, LVM_GETITEM, 0, addr lvi2		mov eax, lvi2.state		and eax, LVIS_SELECTED		.if eax		    jmp the3nd		.endif		invoke SendMessage, ListHwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED		mov NewPos, eax		.while NewPos != -1		        mov eax, NewPos			mov lvi2.iItem, eax		        mov lvi2.iSubItem, 0			mov lvi2.cchTextMax, 55d			m2m lvi2.pszText, offset buf			mov lvi2.stateMask, -3			mov lvi2.imask, LVIF_STATE or LVIF_IMAGE or 10h or LVIF_PARAM or LVIF_TEXT			invoke SendMessage, ListHwnd, LVM_GETITEM, 0, addr lvi2			mov edx, lvhti.iItem			mov lvi2.iItem, edx			invoke SendMessage, ListHwnd, LVM_INSERTITEM, 0, addr lvi2			mov iRetv, eax			xor edx, edx			mov edx, NewPos			.if lvi.iItem < edx			        xor edx, edx				mov edx, lvhti.iItem				inc edx				mov lvhti.iItem, edx			.endif			xor edx, edx			mov edx, NewPos			.if iRetv <= edx			    inc edx				mov NewPos, edx			.endif			.if iRetv > edx			        mov edx, iRetv				dec edx				mov Highlight, edx			.elseif                         mov edx, iRetv                				mov Highlight, edx			.endif			xor ebx, ebx			.while ebx < 3			    mov lvi.iSubItem, ebx				mov lvi.cchTextMax, 55h				m2m	lvi.pszText, offset buf				invoke SendMessage, ListHwnd, LVM_GETITEMTEXT, NewPos, addr lvi 				invoke SendMessage, ListHwnd, LVM_SETITEMTEXT, iRetv, addr lvi				inc ebx			.endw			invoke SendMessage, ListHwnd, LVM_DELETEITEM, NewPos, 0		        invoke SendMessage, ListHwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED			mov NewPos, eax			invoke SetItemHighlight, ListHwnd, Highlight		.endw		invoke ResetFirstItem, ListHwndthe3nd:

 

MasmGui.rar

  • Like 1

Share this post


Link to post

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
Sign in to follow this  
×
×
  • Create New...