Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

Why doesn't this simple code work ... Find similar branches


Kost   (2001-12-15 13:06) [0]

There is a form TForm1. On it is placed the "experimental button" BitBtn1.
There is a desire, by clicking on another button - Button1 to do the following:
- draw a BitBtn1 image onto a canvas bitmap canvas using PaintTo
- bring the resulting bitmap to the outline of the form

DOES NOT WORK! BitBtn1 is not drawn in bitmap! WHY! WHERE AM I AM NOT RIGHT?

procedure TForm1.FormCreate (Sender: TObject);
begin
// Create a bitmap
bmp: = TBitmap.Create;
bmp.Width: = 150;
bmp.Height: = 150;
end;

procedure TForm1.Button1Click (Sender: TObject);
begin
// When you click on the button, draw BitBtn1 on the canvas bitmap
BitBtn1.PaintTo (bmp.Canvas.Handle, 0, 0);
Invalidate; // To cause the form to be redrawn
end;

procedure TForm1.FormPaint (Sender: TObject);
begin
// Display the bitmap form
Canvas.Draw (0,0, bmp);
end;



Song   (2001-12-15 22:18) [1]

Why are you:
1) draw canvas with PaintTo? You can directly set the glyph through Canvas.Draw - this will be more correct.
2) redraw the form? you just need to redraw the control that you updated, i.e.
either like this:
With BitBtn1 Do
Begin
UpDate
Invalidate
End;

either just BitBtn1.RePaint;



Kost   (2001-12-16 12:25) [2]

This example I wanted to show that in the bitmap (more precisely, on the canvas of the bitmap) it is impossible to draw TBitBtn (or TButton) using PaintTo.
WinControl "s has such a member function
WinControl.PaintTo (DC: HDC; X, Y: integer)
with the help of which, allegedly, you can draw an image of the WinControl on any canvas. I tried to draw a button image (TBitBtn) on the canvas of the bitmap. Does not work. Conducted research with other WinControls, it turns out, for example, with TPanel. Te the image of the panel can be transferred to the bitmap using PaintTo. TBitBtn image, I repeat, for some reason this function is not drawn into the bitmap.
Those. This function for different WinControls works as God puts on the soul.



Song   (2001-12-16 22:31) [3]

I think the whole problem is not in PaintTo, but in DC (type HDC), it is not correctly indicated in the case of TBitBtn, i.e. the system returns an incorrect handle for the button canvas: ((



Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top





Memory: 0.55 MB
Time: 0.034 c
1-22078
DJ X
2001-12-15 16:11
2002.01.08
Conversion, Registry, INI


3-21939
SAN
2001-12-04 16:01
2002.01.08
MSSQL


4-22467
Shadow
2001-11-01 15:46
2002.01.08
TOPMOSTS


4-22503
Yura
2001-11-05 20:11
2002.01.08
Enter a string in the window


4-22491
NikRus
2001-11-04 18:09
2002.01.08
Is it possible to intercept keystrokes: Ctrl + Esc, Ctrl + Alt + Del





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Spanish swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada Khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish