Jump to content
Tuts 4 You

How to use ComboBox and GetClipboard


Blue

Recommended Posts

Hi all,

I gotta stuck in an assembly project, I need to do two thing in it. :dunno:

First one is I am using a combo box in it, so I need to know that how to use combo box to add lists in it, and how to get that which one is selected ? Also I want to get the selected list value from Combo box in Digits like, I want to prepare combo box list like this :

1. XXXXX

2. YYYYY

3. ZZZZZ

And want to take selected value back in Numeric form like 1,2 and 3.

The second question is that, how to get the clipboard data in a temp buffer.

I tried the following code, but it's giving me waste

local ClipHwnd:DWORD
Invoke OpenClipboard,NULL
.If eax
invoke GetClipboardData, CF_TEXT
.If eax != 0
invoke GlobalLock, eax
mov ClipHwnd, eax
; Do something with clipboard text here!
; ClipHwnd == pointer to text
invoke GlobalUnlock, ClipHwnd
.endif
invoke CloseClipboard
.endif

I taken this code from winasm forum, where xsp!der told that using edx instead of ClipHwnd solves the matter, but in my case. It is not working.

Ref : http://www.winasm.net/forum/index.php?showtopic=3676

Please help in solving this problem. :worthy:

Link to comment

1. CB_ADDSTRING + CB_GETCURSEL

2. ClipHWnd will hold the address of the text, just strcpy it somewhere and thats it

For extra safety you might want to call IsClipboardFormatAvailable(CF_TEXT) before trying to get the text

Edited by Killboy
Link to comment

1) MASM32 example: http://members.a1.net/ranmasaotome/masm32/Combobox.zip

2) Your clipboard code is buggy in several ways. Try this one:


local ClipHwnd : DWORD
local Buffer[4096] : BYTE Invoke OpenClipboard,NULL
.If eax
invoke GetClipboardData, CF_TEXT
.If eax != 0
mov ClipHwnd, eax
invoke GlobalLock, eax
; If you want to have the text to be available after calling
; GlobalUnlock and CloseClipboard, you MUST copy it to your own buffer
invoke lstrcpy, ADDR Buffer, eax
invoke MessageBox, 0, ADDR Buffer, 0, 0
invoke GlobalUnlock, ClipHwnd
.endif
invoke CloseClipboard
.endif

Warning - My code does not check for string length, so buffer overflow will happen, if there's more than 4096 characters in clipboard.

Link to comment

Thank you Kao and Killboy.

Problem solved. :worthy:

But how to to take the value of selected list in number like 1,2,3 etc ?

Edited by Blue Indian
Link to comment

Thank you Kao and Killboy.

Problem solved. :worthy:

But how to to take the value of selected list in number like 1,2,3 etc ?

CB_GETCURSEL :ermm:

add 1 to the return value and you have your number 1, 2, or 3

Link to comment

Next time state the prog lang in a tag [MASM] in the title so people (like me, i thought it was a Delphi Q) won't get confused.

Link to comment

Next time state the prog lang in a tag [MASM] in the title so people (like me, i thought it was a Delphi Q) won't get confused.

Given that his post contains an MASM example, its fairly easy to tell what language its in. You'd know that if you were a programmer and didn't just copy everyone elses work.

  • Like 1
Link to comment

Given that his post contains an MASM example, its fairly easy to tell what language its in. You'd know that if you were a programmer and didn't just copy everyone elses work.

If you don't have anything clever to say, don't reply at all Wiccaan.

I doubt the only thing you can make is a trainer, can't wait for your next tutorial on how to use Debugging APIs.

Oh, btw, i said in the Title of the thread, not in the content of it, saves time from getting inside here and see if it's something else, read before you reply, you're such a "programmer", i don't want to tell you how some of the CEF legends talk about you in the back.

Edited by rotem156
Link to comment

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