Somebody knows how to implement a textbox in VB 4.0? 
Author Message
 Somebody knows how to implement a textbox in VB 4.0?

I'm writing a graphics program like PaintBrush. I can do lines, circles,
boxes but i have a problem to implement a text box. I draw all this
things in a picture box. I've been trying to implement the text box with
a vb textbox but I got a lot of problems. I almost resolve all problems
but i've get a big one: I save the picture with SavePicture as .BMP but
the text boxes don't save along with the picture. Somebody Knows a way to
save it as .BMP or to change the text box contents to graphics in the
text boxes positions. I've been trying this during two months, please
help me.

Jhon Hamaker gave me this tip:
    you will need to use the api.
this works fantastic (it is actually better than paintbrushs' method...
and faster):
you can build what appears to be a 'text box' on a DC by doing this:
get the bounding rectangle of where you want your text, (the user usually
draws the rectangle)
bitblt the area you want to type on into a memory dc (currentstateDC),
bitblt another copy into a memory dc (backupDC),
draw a framed rectange onto your original DC (drawfocusrectangle works
great), create a caret for the window that owns your original DC,
do until done typing
  capture the keypress events and add the charater to a static or global
string, bitblt backupDC onto currentstateDC, draw the text onto the
currentstateDC, and bitblt the currentstateDC onto the original DC (your
drawing programs image)
    update caret position
loop
destroy the caret, currentstateDC, and backupDC,
erase the bounding rectangle
now your done...
what i just described looks like you are typing directly on the image
with a
frame around the bounds..
if you don't want the special effects of directly typing on the picture
then
use an input box or something to get a string to draw.
get a bounding rectange of the area you need to type,
and use the drawtext api to print the text onto your picture with the
wordwrap flag set...

I think this is the solution but the problem is I have not too much
experience with the API, Can Somebody help me...
  All I want to do is the user can write text in textboxes (like
PaintBrush, Paint or like in Word) and can save it as .BMP along with
the graphics in the picture box.

Thanks in advance.



Wed, 13 Sep 2000 03:00:00 GMT  
 Somebody knows how to implement a textbox in VB 4.0?

Yeap, use the textbox for editing and then transfer the content of the
textbox into a label that you'll size and move where the textbow was (hiding
the textbox). Then save the picture... It'll work because the Label is a
graphic control. Of course, the label has to be contained in the picture box
or it won't be on top of the picture box.

Also and nicer, use the text box for the input then when the textbox loses
focus, hide it and set the picturebox coordonates to where the textbox was
and simply "Print" on the picturebox :
    Text1.Visible = 0
    Picture1.CurrentX = Text1.Left
    Picture1.CurrentY = Text1.Top + Picture1.TextHeight("d")
    Picture1.Print Text1.Text
The drawback is that you'll have to handle the text wrapping yourself...

Hope this helps.

julien.

Quote:

> I'm writing a graphics program like PaintBrush. I can do lines, circles,
> boxes but i have a problem to implement a text box. I draw all this
> things in a picture box. I've been trying to implement the text box with
> a vb textbox but I got a lot of problems. I almost resolve all problems
> but i've get a big one: I save the picture with SavePicture as .BMP but
> the text boxes don't save along with the picture. Somebody Knows a way to
> save it as .BMP or to change the text box contents to graphics in the
> text boxes positions. I've been trying this during two months, please
> help me.

> Jhon Hamaker gave me this tip:
>     you will need to use the api.
> this works fantastic (it is actually better than paintbrushs' method...
> and faster):
> you can build what appears to be a 'text box' on a DC by doing this:
> get the bounding rectangle of where you want your text, (the user usually
> draws the rectangle)
> bitblt the area you want to type on into a memory dc (currentstateDC),
> bitblt another copy into a memory dc (backupDC),
> draw a framed rectange onto your original DC (drawfocusrectangle works
> great), create a caret for the window that owns your original DC,
> do until done typing
>   capture the keypress events and add the charater to a static or global
> string, bitblt backupDC onto currentstateDC, draw the text onto the
> currentstateDC, and bitblt the currentstateDC onto the original DC (your
> drawing programs image)
>     update caret position
> loop
> destroy the caret, currentstateDC, and backupDC,
> erase the bounding rectangle
> now your done...
> what i just described looks like you are typing directly on the image
> with a
> frame around the bounds..
> if you don't want the special effects of directly typing on the picture
> then
> use an input box or something to get a string to draw.
> get a bounding rectange of the area you need to type,
> and use the drawtext api to print the text onto your picture with the
> wordwrap flag set...

> I think this is the solution but the problem is I have not too much
> experience with the API, Can Somebody help me...
>   All I want to do is the user can write text in textboxes (like
> PaintBrush, Paint or like in Word) and can save it as .BMP along with
> the graphics in the picture box.

> Thanks in advance.



Thu, 14 Sep 2000 03:00:00 GMT  
 Somebody knows how to implement a textbox in VB 4.0?

I tried with the 2 ways:
 1) I transfer the text of textbox to the label and then hide the
textbox. I save the graphic with SavePicture and finish the program. I
run again the program and when I load the graphic with LoadPicture
(Picture1.Picture=LoadPicture("graphic.bmp")) i have  the same problem,
now the labels don't save along with the graphics. Do I have to change
some controls properties?
 2) I tried with the Picture1.Print method but when I typed text with
Enter keys the text doesn't place in the right position.

 ?Do you know why? or I have to use the API.
 Thanks.
Omar Lopez.

Quote:

> Yeap, use the textbox for editing and then transfer the content of the
> textbox into a label that you'll size and move where the textbow was (hiding
> the textbox). Then save the picture... It'll work because the Label is a
> graphic control. Of course, the label has to be contained in the picture box
> or it won't be on top of the picture box.

> Also and nicer, use the text box for the input then when the textbox loses
> focus, hide it and set the picturebox coordonates to where the textbox was
> and simply "Print" on the picturebox :
>     Text1.Visible = 0
>     Picture1.CurrentX = Text1.Left
>     Picture1.CurrentY = Text1.Top + Picture1.TextHeight("d")
>     Picture1.Print Text1.Text
> The drawback is that you'll have to handle the text wrapping yourself...

> Hope this helps.

> julien.



Sat, 16 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Anyone know how to implement panes in VB?

2. Does anyone know how to implement UNIONS in VB types

3. HELP : Trying to implement cross table queries in VB 4.0

4. Implementing Colour in VB 4.0

5. Implementing Colour in VB 4.0 via Control Panel

6. How to implement Scrolling Textbox in VB?

7. Somebody who knows about Access97 Please Help!

8. somebody know a way to delegate events async?

9. I am trying igain - somebody must know

10. Trouble finding error (somebody must know this one)

11. Somebody has got to know anything about the RichText Box

12. Does somebody knows why this happens????

 

 
Powered by phpBB® Forum Software