Solved

Problem ...PictureBox DC in VB and TextOut in DLL

Posted on 2001-06-15
15
259 Views
Last Modified: 2008-02-01
hmm..

I have a picturebox (AutoRedraw is TRUE) ..

and a dll for text out to DC.

'-------------in VB Project.
'in the module
Declare function fnTextOut lib "test.dll" (byval hDCtmp as long) as long

'in the form
Private Sub Command1_Click()
  label1 = fnTextOut(Picture1.hDC)
End Sub

//in Dll project (VC 6.0)
unsigned char tmp[80];
#define DLLexport __declspec( dllexport )
DLLexport BOOL WINAPI fnTextOut(HDC hdc)
{
  sprintf(tmp, "test printf");
  TextOut(hdc, 0, 0, tmp, strlen(tmp));
  return TRUE;
}

// it's all.. surely..dll frame is omitted.

# problem is..
the text "test printf" is not appeared..

but if i toggle test program with other program(and if it is overraped), text is appeard...

Why does the text not appeared automatically ?

Is there any thing to do in DLL for display text ?

thank you
0
Comment
Question by:can9999
  • 4
  • 3
  • 3
  • +4
15 Comments
 
LVL 5

Expert Comment

by:gbaren
ID: 6195632
Try form1.refresh after the call to the DLL.

Also, you can very simply write text to a picture box in VB.

0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6195664
gbaren is right, using the standard VB functions you can do:

Picture1.Print "Hello"

To put the text in the picturebox, set the x/y coordinates using
Picture1.CurrentX = 100
Picture1.CurrentY = 200
0
 
LVL 4

Expert Comment

by:nutwiss
ID: 6195736
why the hell have you got a textout() wrapper in a separate DLL? You can call it perfectly well, direct from VB.......
0
 
LVL 4

Expert Comment

by:nutwiss
ID: 6195738
Public Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
0
 
LVL 1

Author Comment

by:can9999
ID: 6195997
there are some reason.

because .dll execute many things.

One of the things is "display raw image data".. and "text out of information"

So I need to know how to text out in dll.

0
 
LVL 4

Expert Comment

by:nutwiss
ID: 6196024
set autoredraw to false, or call .refresh

one OR the other
0
 
LVL 4

Expert Comment

by:nutwiss
ID: 6196026
not both
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:gbaren
ID: 6196175
Set Autoredraw to True AND Form.Refresh after the call to the DLL.

0
 
LVL 27

Expert Comment

by:Ark
ID: 6197422
Hi
Use API GetDC(Picture1.hWnd) instead of Picture1.hDC  - they are different.
Do you need code?

Cheers
0
 
LVL 27

Expert Comment

by:Ark
ID: 6197426
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hWnd As Long) As Long


 label1 = fnTextOut(GetDC(Picture1.hWnd))

Cheers
0
 
LVL 1

Author Comment

by:can9999
ID: 6197550
there is no answer what i want..
0
 
LVL 5

Accepted Solution

by:
gbaren earned 100 total points
ID: 6197567
Did you try refreshing the form after the call to the DLL?

Feedback please.
0
 
LVL 27

Expert Comment

by:Ark
ID: 6197609
Can you please send your C dll at ark@fesma.ru

Cheers
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7136175
Hi can9999,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept gbaren's comment(s) as an answer.

can9999, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7173322
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now