Jan 30th, 2003, 12:15 AM
#1
Thread Starter
Frenzied Member
DrawText RECT
Why do i get a error? i dont know RECT really.
VB Code:
RECT lbl;
lbl.left = 20;
lbl.top = 100;
lbl.right = 200;
lbl.bottom = 30;
::DrawText(NULL,"Jason",-1,lbl,DT_CENTER);
E:\Program Files\Microsoft Visual Studio\MyProjects\class2 test\main.cpp(48) : error C2664: 'DrawTextA' : cannot convert parameter 4 from 'struct tagRECT' to 'struct tagRECT *'
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 30th, 2003, 12:19 AM
#2
transcendental analytic
pass the address &lbl
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Jan 30th, 2003, 12:29 AM
#3
Thread Starter
Frenzied Member
thanks no error but no text maybe because
in
VB Code:
int DrawText(
HDC hDC, // handle to DC
LPCTSTR lpString, // text to draw
int nCount, // text length
LPRECT lpRect, // formatting dimensions
UINT uFormat // text-drawing options
);
How do i use :
HDC hDC, // handle to DC
I tried MSDN but cant understand maybe someone can help me thanks
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 30th, 2003, 01:02 AM
#4
Hyperactive Member
Code:
HDC hdc = BeginPaint(hWnd, &ps);
//paint here
EndPaint(hWnd, &ps);
Jan 30th, 2003, 01:22 AM
#5
Thread Starter
Frenzied Member
ok sort of helped but still nothing i got
Code:
RECT lbl;
lbl.left = 30;
lbl.top = 300;
lbl.right = 200;
lbl.bottom = 30;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
::DrawText(hdc,"Jason",-1,&lbl,DT_CENTER);
EndPaint(hwnd, &ps);
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 30th, 2003, 01:28 AM
#6
Hyperactive Member
Do you have your code in WM_PAINT message?
Jan 30th, 2003, 01:58 AM
#7
Thread Starter
Frenzied Member
I got it like but no good my window bg is white
Code:
case WM_PAINT:
{
RECT lbl;
lbl.left = 30;
lbl.top = 90;
lbl.right = 200;
lbl.bottom = 30;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
::DrawText(hdc,"Jason",-1,&lbl,DT_CENTER);
EndPaint(hwnd, &ps);
}
break;
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 30th, 2003, 08:50 AM
#8
rect.top = 90
rect.bottom = 30
Positive y axis goes down. Your bottom is higher than your top.
All the buzzt
CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Jan 30th, 2003, 10:35 AM
#9
Thread Starter
Frenzied Member
LOL i thought that ment like how far apart from the top lol. Thankx alot it worked great.
Last edited by JasonLpz; Jan 30th, 2003 at 11:34 AM .
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 30th, 2003, 11:34 AM
#10
Thread Starter
Frenzied Member
ok now i go it , it works great but i can i run this from anytime i want?
Code:
case WM_PAINT:
{
RECT lbl;
lbl.left = 6;
lbl.top = 10;
lbl.right = 200;
lbl.bottom = 33;
RECT lbl2;
lbl2.left = 6;
lbl2.top = 38;
lbl2.right = 200;
lbl2.bottom = 66;
RECT lbl3;
lbl3.left = 6;
lbl3.top = 60;
lbl3.right = 200;
lbl3.bottom = 89;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
::DrawText(hdc,"First Name",-1,&lbl,DT_LEFT);
::DrawText(hdc,"Last Name",-1,&lbl2,DT_LEFT);
::DrawText(hdc,"Enter NO. To look up.",-1,&lbl3,DT_LEFT);
EndPaint(hwnd, &ps);
}
break;
do i do a refresh? or like update or i cant?
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 30th, 2003, 12:30 PM
#11
You need to send a WM_PAINT message to yourself.
Code:
SendMessage(hwnd, WM_PAINT, 0, 0)
maybe?
Jan 30th, 2003, 01:14 PM
#12
First you invalidate a region of your window (or all of it):
Code:
InvalidateRect(hwnd, &rectToInvalidate, TRUE);
// or for the whole window
InvalidateRect(hwnd, NULL, TRUE);
Then you can either wait for windows to ask your app to redraw (it will do that once your app is idle) or force immediate redrawing:
Code:
UpdateWindow(hwnd);
All the buzzt
CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Jan 30th, 2003, 01:49 PM
#13
Thread Starter
Frenzied Member
oh i c ok thanks i should be buying a couple of api books this week maybe. wheni do i wont ask such small questions anymore , cuz i know its a pain thankz
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 30th, 2003, 06:33 PM
#14
Thread Starter
Frenzied Member
also can i drawtext to another program?
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 30th, 2003, 06:36 PM
#15
Yes, given that you find out its hwnd. There are many ways to do that, the most common being FindWindow.
Then you call GetDC on that window and draw whatever you want into that dc. Call ReleaseDC when you're finished.
But note that everything you draw is gone once the other app repaints. Also it is considered bad manners for an app to do such a thing.
All the buzzt
CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Jan 30th, 2003, 08:32 PM
#16
Thread Starter
Frenzied Member
thx i will respect other developers programs. and also if i put that code in a timer will it work ok?
HDC hdc2 = ::GetDC(i) ? would work
ADDED
Code:
HDC hdc2 = ::GetDC(i);
::DrawText(hdc2,"Made By: Jason Lopez aka JayWare",-1,&lbl2,DT_LEFT);
ReleaseDC (i,hdc2);
Last edited by JasonLpz; Jan 30th, 2003 at 08:39 PM .
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 31st, 2003, 06:33 AM
#17
All the buzzt
CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Jan 31st, 2003, 08:06 AM
#18
Thread Starter
Frenzied Member
so it will stay on the other form. So how would i do it . That code i got above dont work.
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 31st, 2003, 08:08 AM
#19
Thread Starter
Frenzied Member
ok yes it does work lol thanks
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Jan 31st, 2003, 08:09 AM
#20
Fanatic Member
could you subclass it? or would your winproc be called first and then the original proc overwrite the screen?
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
Jan 31st, 2003, 03:13 PM
#21
Thread Starter
Frenzied Member
i got it to work great in a timer just send WM_PAINT and walla! here is a sample of what i did. if you want the source tell me. This adds some text to notepad in win98 se and winxp(tested). this is the exe ziped up at 52kb.
Attached Files
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width