• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

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

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
can9999
Asked:
can9999
  • 4
  • 3
  • 3
  • +4
1 Solution
 
gbarenCommented:
Try form1.refresh after the call to the DLL.

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

0
 
TimCotteeHead of Software ServicesCommented:
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
 
nutwissCommented:
why the hell have you got a textout() wrapper in a separate DLL? You can call it perfectly well, direct from VB.......
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
nutwissCommented:
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
 
can9999Author Commented:
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
 
nutwissCommented:
set autoredraw to false, or call .refresh

one OR the other
0
 
nutwissCommented:
not both
0
 
gbarenCommented:
Set Autoredraw to True AND Form.Refresh after the call to the DLL.

0
 
ArkCommented:
Hi
Use API GetDC(Picture1.hWnd) instead of Picture1.hDC  - they are different.
Do you need code?

Cheers
0
 
ArkCommented:
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hWnd As Long) As Long


 label1 = fnTextOut(GetDC(Picture1.hWnd))

Cheers
0
 
can9999Author Commented:
there is no answer what i want..
0
 
gbarenCommented:
Did you try refreshing the form after the call to the DLL?

Feedback please.
0
 
ArkCommented:
Can you please send your C dll at ark@fesma.ru

Cheers
0
 
DanRollinsCommented:
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
 
Computer101Commented:
Comment from expert accepted as answer

Computer101
E-E Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 4
  • 3
  • 3
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now