-
Aug 15th, 2022, 01:12 PM
#1
Thread Starter
New Member
setwindowlongptrw vs setwindowlongptr
hey everyone
i have difficulties in understanding what's going on with UNICODE.
example1:
I create a listbox with createwindow (not the UNICODE)
i subclass it with the unicode version
SetWindowLongPtrW
in the subclassed procedure i use ANSI CallWindowProc
I use UNICODE SendMessageW to send UNICODE strings
and I Use ANSI SendMessage to send ANSI strings
everything seems to be OK
the subclassed listbox control got the UNICODE strings
and the ANSI string with no problem..
example2:
the same thing as example1
except that the control is EDIT
whether i send ANSI whether UNICODE strings
at the end i get a truncated string
that means there was a mismatch between ANSI and UNICODE
to fix this, in the subclassed procedure I use the UNICODE CallWindowProcW
now the UNICODE strings arrive correctly to the control.
my question is:
is there some constant rule when to use CallWindowProcW/CallWindowProc
why with listbox i DONT need the UNICODE
and with EDIT I MUST use the UNICODE CallWindowProcW
I really need to know what's going on so I can use ANSI/UNICODE correctly.
third question is
i create custom control
and i want it to optionally handle UNICODE strings via sendmessageW sent to it.
when I create it, do i MUST use CreateWindowExW or it's OK to use CreateWindowEx ?
some details:
I use GPP.
I dont use vb6 AT ALL
i use CreateWindowEx to create all controls
when i compile i DONT use #define UNICODE (and I DONT want to use it)
so my app is actually ANSI
and when i need UNICODE i use it as described above
thanks in advanced.
Last edited by jim_box; Aug 15th, 2022 at 01:46 PM.
-
Aug 18th, 2022, 04:45 AM
#2
Re: setwindowlongptrw vs setwindowlongptr
Are you trying to create a listbox using the API?
-
Aug 18th, 2022, 08:20 AM
#3
Re: setwindowlongptrw vs setwindowlongptr
Moved from Visual Basic 6 and Earlier to Other Programming Languages since this thread has nothing to do with VB6.
-
Oct 12th, 2022, 07:48 AM
#4
Thread Starter
New Member
Re: setwindowlongptrw vs setwindowlongptr
I solved it.
to work with mixed ansi/unicode there is no need to define UNICODE:
* When you want to create an existing unicode control,
* Use the unicode CreateWindowW
* To subclass/unsubclass the hwnd return from CreateWindowW
use unicode SetWindowLongPtrW
* in your subclassed WNDPROC use unicode CallWindowProcW
* you can now send unicode strings to this hwnd with unicode SendMessageW
* you can still send ansi strings to this hwnd with ansi SendMessage
windows system will change for you the following messages from ansi strings to unicode
WM_GETTEXT, WM_SETTEXT and some more
* to create a custom hwnd that can send/receive UNICODE strings with WM_GETTEXT/WM_SETTEXT, ...
you need to register/unregister it with unicode RegisterClassExW/UnregisterClassW
and then follow the above instructions.
with a custom UNICODE hwnd you need to use unicode DefWindowProcW
So to send unicode strings to EDIT control I just had to create it with unicode CreateWindowW.
with ListBox I didn't have to this, I could use ansi CreateWindow and still send UNICODE string with unicode SendMessageW
I don't know the reason for this, I guess it doesn't matter.
Last edited by jim_box; Oct 12th, 2022 at 07:53 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|