V.3.1
ctlUniCanvas

Unicode API window that you can use like a normal DC. You can draw into this area using normal API functions and you can receive events with Unicode data for KeyPress, KeyDown, KeyUp. The "Label Editor" dialog used in my Dynamic HTML Editor program uses a ctlUniCanvas object to catch Unicode keys ;-)
This control
supports IME input.
>>Common properties

Some Properties/Methods:
ClientWidth / ClientHeight gives you the client area of the control
IsInIME You can use this property for knowing if the KeyPress, KeyDown and KeyUp events have been raised by the active IME window associated to your control. By using this property in the KeyPress event you can avoid the IME text. See here.
Refresh Force the redraw of the control, pass the "bNow" flag to "True" to redraw it immediately (without waiting for Windows events).
TrapTabKey permits you to trap the tab character
UseMouseSetCapture permits you to capture the mouse movements even if the mouse is out of the control (when pressing the mouse button into the control and then exiting from it maintaining the button pressed) like a normal PictureBox control
Events:
CanvasGotFocus / CanvasLostFocus raised when the control get/lost the focus. This works, the VB6 one don't.
IMEComposition see here
KeyDown / KeyPress / KeyUp the Keyascii or Keycode parameter can have negative values (because the Unicode uses 1 unsigned integer and the VB6 declaration of these events has only 1 signed integer; so no data is lost but the value may arrive negative).
You can manage the KeyAscii / KeyCode value simply by using the
clsCommonWrapper.ChrW or AscW methods.
It's also possible to obtain the real Unsigned Integer (using a VB6 long) from the negative value simply by converting the KeyAscii / KeyCode value to a Long using the
clsCommonWrapper.MakeDWord (KeyAscii, 0) method.
Paint raised when the control need to be redrawn
How to use this control:
Simply manage the Paint Event, it gives you a Device Context that you can use to draw. The DC passed has no memory, it's like a standard Window DC. Useful to catch Unicode characters using the KeyDown/KeyUp/KeyPress events.

You can use a clsMemDC object to create and manage Windows DC.
A ctlUniCanvas object used to make an UNICODE text editor
(Dynamic HTML Editor)
Sample:
Draw a ctlUniCanvas object into a Form then:
Private oMemDC As New clsMEMDC
Private oWrap As New clsCommonWrapper

Private Sub Form_Load()
   
   
'Create the memory DC
   oMemDC.CreateDC ctlUniCanvas1.ClientWidth, _
                   ctlUniCanvas1.ClientHeight
   
   
'Draw into DC using Windows API
   oWrap.DrawRectCoords oMemDC.hDC, 0, 0, 100, 100, vbRed, True
   
End Sub

Private Sub ctlUniCanvas1_Paint(lHDC As Long)
   
'Draw the memory DC to the visible DC
   oMemDC.PaintPicture lHDC
End Sub
http://www.hexagora.com
Thu, 20 Oct 2011 07:20:48 UT
Copyright 2003-11 by Lorenzi Davide