Handle to a DeviceContext hdc

  • Thread starter Thread starter George Hester
  • Start date Start date
G

George Hester

So I trie it like this:

In my UserForm:

Private Sub CommandButton1_Click()
'............
hOldFont = SelectObject(Me.TheDeviceContext, hFont)
'............
End Sub
Public Function TheHandle() As Long
TheHandle = FindWindow(vbNullString, Me.Caption)
End Function
Public Function TheDeviceContext() As Long
TheDeviceContext = GetWindowDC(Me.TheHandle)
End Function

Here is the rest:
http://support.microsoft.com/default.aspx?scid=kb;en-us;158870&Product=vbb

In Visual Basic 6 SP5 this does exacrly what it is supposed to do. But in VBA in Outlook 2002 SP2 I get no errors but I don't get the Kanji characters. I believe it is because I did not make the DeviceContext handle correctly. Any ideas. I'd prefer to write the Kanji characters to a message box and I suppose once I get this to work for the window UserForm I should be able to get it to work for a message box as well. Thanks.
 
Here's what I've gotten in Outlook 2002 VBA:



It should be this from VB:



--
George Hester
__________________________________
So I trie it like this:

In my UserForm:

Private Sub CommandButton1_Click()
'............
hOldFont = SelectObject(Me.TheDeviceContext, hFont)
'............
End Sub
Public Function TheHandle() As Long
TheHandle = FindWindow(vbNullString, Me.Caption)
End Function
Public Function TheDeviceContext() As Long
TheDeviceContext = GetWindowDC(Me.TheHandle)
End Function

Here is the rest:
http://support.microsoft.com/default.aspx?scid=kb;en-us;158870&Product=vbb

In Visual Basic 6 SP5 this does exacrly what it is supposed to do. But in VBA in Outlook 2002 SP2 I get no errors but I don't get the Kanji characters. I believe it is because I did not make the DeviceContext handle correctly. Any ideas. I'd prefer to write the Kanji characters to a message box and I suppose once I get this to work for the window UserForm I should be able to get it to work for a message box as well. Thanks.
 
Just required:

Private Sub CommandButton1_Click()
Dim hFont As Long
Dim hOldFont As Long
Dim MyUnicode(3) As Unicode
Dim di
Dim hDCMemory As Long
hDCMemory = Me.TheDeviceContext
hFont = CreateFontA(32, 16, 0, 0, 400, 0, 0, 0, 128, 3, 2, 1, 49, _
"MS Gothic")
hOldFont = SelectObject(hDCMemory, hFont)
MyUnicode(0).h = CByte(140)
MyUnicode(0).l = CByte(128)
MyUnicode(1).h = CByte(140)
MyUnicode(1).l = CByte(127)
MyUnicode(2).h = 0
MyUnicode(2).l = 0
di = TextOutU(hDCMemory, 100, 100, MyUnicode(0), 2)
Call SelectObject(hDCMemory, hOldFont)
DeleteObject (hFont)
End Sub
Public Function TheHandle() As Long
TheHandle = FindWindow(vbNullString, Me.Caption)
End Function
Public Function TheDeviceContext() As Long
TheDeviceContext = GetWindowDC(Me.TheHandle)
End Function

This will give you the handle to a device context (hDC) in VBA forms. The next step here is to see if we can make a Picture Box in the form.

--
George Hester
__________________________________
Here's what I've gotten in Outlook 2002 VBA:



It should be this from VB:



--
George Hester
__________________________________
So I trie it like this:

In my UserForm:

Private Sub CommandButton1_Click()
'............
hOldFont = SelectObject(Me.TheDeviceContext, hFont)
'............
End Sub
Public Function TheHandle() As Long
TheHandle = FindWindow(vbNullString, Me.Caption)
End Function
Public Function TheDeviceContext() As Long
TheDeviceContext = GetWindowDC(Me.TheHandle)
End Function

Here is the rest:
http://support.microsoft.com/default.aspx?scid=kb;en-us;158870&Product=vbb

In Visual Basic 6 SP5 this does exacrly what it is supposed to do. But in VBA in Outlook 2002 SP2 I get no errors but I don't get the Kanji characters. I believe it is because I did not make the DeviceContext handle correctly. Any ideas. I'd prefer to write the Kanji characters to a message box and I suppose once I get this to work for the window UserForm I should be able to get it to work for a message box as well. Thanks.
 
Back
Top