Author |
Topic: Edit control with Unicode-only language (Read 7478 times) |
|
Nick
New Member
member is offline


Gender: 
Posts: 33
|
 |
Re: Edit control with Unicode-only language
« Reply #19 on: Sep 15th, 2011, 09:11am » |
|
on Sep 15th, 2011, 08:04am, Richard Russell wrote:| I wonder if you inadvertently called SendMessage rather than PostMessage, thereby invalidating your experiment? |
|
Yes indeed I did Richard - sorry.
Quote:| Anyway, the good news is that if the issue is related to the Unicode-ness of the message pump that is easily sorted. BB4W dialogue boxes (created in the WINLIB2 library) use their own private message pump |
|
I just modified WINLIB2 (as shown at the end) and used it to create a edit control within a dialogue box.
It works *PERFECTLY* - even right-to-left Farsi (Persian)
Thank you SO much again for such an amazingly flexible BASIC - this is really terrific. And thank you too for your responsiveness to these tedious threads! But this is real progress, and I suspect to others also.
So, just to be sure, you are saying that if I make a similar addition to WINLIB5 (for rich edit controls) then I can similarly have a modified message pump?
In which case, my only issue is how to code this - it involves assembly which i am REALLY rusty on - but the Russian guy is sharp - he will doubtless figure it out.
I will tell him not to bother hacking the BBC4W runtime - I never intended it as a long-term solution - just a way of getting him to prove his point. There is no need for that anyway now.
Thank you again Richard,
Nick
************** MODIFIED "W" VERSION OF WINLIB2" ***********
REM Dialogue box items: DEF PROC_pushbutton(dlg%,text$,id%,x%,y%,cx%,cy%,style%): style%+=&50010000:LOCAL class%:class%=&80 DEF PROC_checkbox(dlg%,text$,id%,x%,y%,cx%,cy%,style%): style%+=&50010003:LOCAL class%:class%=&80 DEF PROC_radiobutton(dlg%,text$,id%,x%,y%,cx%,cy%,style%):style%+=&50010009:LOCAL class%:class%=&80 DEF PROC_groupbox(dlg%,text$,id%,x%,y%,cx%,cy%,style%): style%+=&50000007:LOCAL class%:class%=&80 DEF PROC_editbox(dlg%,text$,id%,x%,y%,cx%,cy%,style%): style%+=&50810000:LOCAL class%:class%=&81 DEF PROC_static(dlg%,text$,id%,x%,y%,cx%,cy%,style%): style%+=&50000000:LOCAL class%:class%=&82 DEF PROC_listbox(dlg%,text$,id%,x%,y%,cx%,cy%,style%): style%+=&50A10003:LOCAL class%:class%=&83 DEF PROC_combobox(dlg%,text$,id%,x%,y%,cx%,cy%,style%): style%+=&50210000:LOCAL class%:class%=&85 DEF PROC_dlgitem(dlg%,text$,id%,x%,y%,cx%,cy%,style%,class%) LOCAL P%, L% P% = dlg%!12 WHILE (P% AND 3) P% += 1 : ENDWHILE IF (P%+2*LENtext$+26) > dlg%!8 ERROR 0, "No room for dialogue template" : P%!0 = style% P%!4 = 0 P%!8 = (y% << 16) OR x% P%!12 = (cy% << 16) OR cx% P%!16 = &FFFF0000 OR id% P%!20 = class% : SYS "MultiByteToWideChar", 0, 0, text$, -1, P%+22, 65536 TO L% P%!(2*L%+20) = 0 : dlg%!12 = P%+2*L%+24 dlg%!24 += 1 ENDPROC ; REM Display dialogue box: DEF PROC_showdialog(dlg%) : LOCAL H%, I% IF !dlg% <> 0 ENDPROC SYS "CreateThread", 0, 1024, dlg%!4, 0, 0, ^I% TO H% REPEAT SYS "Sleep", 10 : UNTIL !dlg% <> 0 SYS "CloseHandle", H% ENDPROC ; REM Remove dialogue box: DEF PROC_closedialog(dlg%) IF !dlg% = 0 ENDPROC SYS "PostMessageW", !dlg%, 18, 0, 0 REPEAT SYS "Sleep", 10 : UNTIL !dlg% = 0 ENDPROC ; REM Create a new dialogue box: DEF FN_newdialog(title$,x%,y%,cx%,cy%,font%,size%) LOCAL dlg%, msg%, L%, F%, P%, I%, X%, C%, N%, D%, Q%, T%, M% DIM P% 169, msg% 27, dlg% size%-1 WHILE (dlg% AND 3) dlg% += 1 : size% -= 1 : ENDWHILE IF (2*LENtitle$+70) > size% ERROR 0, "No room for dialogue template" : SYS "GetWindowLongW", @hwnd%, -6 TO I% [ OPT 2 .X% push 0 : CALL "PostQuitMessage" : mov eax,1 : ret 16 .C% push dword [esp+16] : push dword [esp+16] : push eax : push @hwnd% : call "SendMessage" cmp word [esp+12], 2 : jz X% ; IDCANCEL .N% mov eax,1 : ret 16 .D% mov eax,[esp+8] : cmp eax,&110 : jz N% : cmp eax,&111 : jz C% xor eax,eax : ret 16 .Q% xchg eax,[dlg%] push eax call "DestroyWindow" ret .T% push 0 ; lParamInit push D% ; lpDialogFunc push @hwnd% ; hWndParemt push dlg%+16 ; lpTemplate push I% ; hInstance call "CreateDialogIndirectParam" mov [dlg%],eax .M% push 0 push 0 push 0 push msg% call "GetMessageW" or eax,eax jz Q% push msg% push dword [dlg%] call "IsDialogMessageW" or eax,eax jnz M% push msg% call "DispatchMessageW" jmps M% ] : dlg%!4 = T% dlg%!8 = dlg%+size% dlg%!16 = &90C800C4 dlg%!20 = 0 dlg%!24 = 0 dlg%!26 = x% dlg%!28 = y% dlg%!30 = cx% dlg%!32 = cy% dlg%!34 = 0 : SYS "MultiByteToWideChar", 0, 0, title$, -1, dlg%+38, 65536 TO L% : dlg%!(2*L%+38) = font% SYS "MultiByteToWideChar", 0, 0, "Arial", -1, dlg%+2*L%+40, 16 TO F% : dlg%!12 = dlg%+2*L%+2*F%+40 = dlg% ; REM Dialogue box control: DEF PROC_dlgctrl(dlg%,text$,id%,x%,y%,cx%,cy%,style%,class$) LOCAL L%,T% PROC_dlgitem(dlg%,text$,id%,x%,y%,cx%,cy%,style%,0) T% = dlg%!12-8 IF (T%+2*LENclass$+6) > dlg%!8 ERROR 0, "No room for dialogue template" SYS "MultiByteToWideChar", 0, 0, class$, -1, T%, 256 TO L% dlg%!12 = T%+2*L%+4 ENDPROC
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Edit control with Unicode-only language
« Reply #20 on: Sep 15th, 2011, 9:36pm » |
|
on Sep 15th, 2011, 09:11am, Nick wrote:| So, just to be sure, you are saying that if I make a similar addition to WINLIB5 (for rich edit controls) then I can similarly have a modified message pump? |
|
Yes. I may need to code it for you, because it requires a good understanding of assembler code, but it shouldn't be difficult. You will end up with your Edit Control running in a different thread (just as it was when you modified the dialogue box example) but there's no particular disadvantage to that - and if you have the luxury of a multi-core CPU it could actually be beneficial in distributing the load more evenly.
I don't routinely create child controls, toolbars, status bars etc. in their own threads because the code becomes more complicated and there's usually no significant advantage. So I would want to meet your requirements with a dedicated solution rather than modifying WINLIB5 itself to do so. Maybe a WINLIB5B would be appropriate.
Richard.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Edit control with Unicode-only language
« Reply #21 on: Sep 16th, 2011, 08:06am » |
|
I've uploaded a new library here:
http://tech.groups.yahoo.com/group/bb4w/files/Libraries/WINLIB5W.BBC
WINLIB5W is a Unicode version of the WINLIB5A library (i.e. for maximum flexibility it requires the parent window handle to be specified as the first parameter in each of the 'create window' calls).
Richard.
|
|
Logged
|
|
|
|
Nick
New Member
member is offline


Gender: 
Posts: 33
|
 |
Re: Edit control with Unicode-only language
« Reply #22 on: Sep 16th, 2011, 6:03pm » |
|
on Sep 16th, 2011, 08:06am, Richard Russell wrote:| I've uploaded a new library here. |
|
Wow - that was fast Richard!!
I had just logged in to thank you for the kind offer and ask how long the new library might take!!
I will have to get a Yahoo account and download it ASAP
Thank you again - I will let you know the result!
Nick
|
|
Logged
|
|
|
|
Nick
New Member
member is offline


Gender: 
Posts: 33
|
 |
Re: Edit control with Unicode-only language
« Reply #23 on: Sep 16th, 2011, 9:31pm » |
|
on Sep 16th, 2011, 08:06am, Richard Russell wrote:
Richard,
Just to let you know that WINLIB5W seems to work perfectly on both XP and Win 7.
I have farmed out an exe to friends who work in other languages to test, but I would be surprised if it does not work for them also. The existing version already worked with right-to-left languages (apart from the "?" issue)
Thank you SO much for this speedy response to the issue. This will really help those who wish to write fully unicode enabled appls with BBC4W.
Congratulations on a really great addition to the programme!
Nick
|
|
Logged
|
|
|
|
|