 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Tim H Guest
|
Posted: Sat Jul 01, 2006 8:33 pm Post subject: Newbie question - RGB function |
|
|
I'm trying to use the RGB function.
Imported with:
"
function RGB(red,green,blue:byte):longword; external 'gdi32.dll';
"
used with:
"
procedure TFrmMyColourCreater.BtnShowClick(Sender: TObject);
begin
paintbox1.Color:= rgb(strtoint(EdtRed.Text),strtoint
(EdtGreen.Text),strtoint(EdtBlue.Text));
end;
"
It compiles but when procedure is run (values of 100 for red, green and
blue):
Error:
" Unable to find an entry point named RGB in DLL gdi32.dll. "
I am using Delphi 2005 personal edition, Delphi.net with VCL
Any help much appreciated.
from Tim Huntington
--- posted by geoForum on http://delphi.newswhat.com |
|
| Back to top |
|
 |
Mike Williams (TeamB) Guest
|
Posted: Sat Jul 01, 2006 8:33 pm Post subject: Re: Newbie question - RGB function |
|
|
Tim H wrote:
| Quote: | I'm trying to use the RGB function.
Imported with:
"
function RGB(red,green,blue:byte):longword; external 'gdi32.dll';
|
Can't you simply use the RGB function that's already defined for you in
the windows unit? It's not really even an API call; if you look at the
source you'll see that it just a one line function that uses bit
shifting operations to combine the R, G, and B values into a COLORREF.
--
-Mike (TeamB) |
|
| Back to top |
|
 |
Finn Tolderlund Guest
|
Posted: Sat Jul 01, 2006 8:33 pm Post subject: Re: Newbie question - RGB function |
|
|
"Tim H" <xxx (AT) xxx (DOT) co.uk> skrev i en meddelelse
news:44a689db (AT) newsgroups (DOT) borland.com...
| Quote: | I'm trying to use the RGB function.
Imported with:
function RGB(red,green,blue:byte):longword; external 'gdi32.dll';
Error:
" Unable to find an entry point named RGB in DLL gdi32.dll. "
|
There is no need to import RGB.
And it's not defined in gdi32, it's a macro, which means you can't import
it. That might explain the error.
There already is a RGB function in the Windows unit, just use that.
--
Finn Tolderlund
http://www.tolderlund.eu/delphi/ |
|
| Back to top |
|
 |
Tim H Guest
|
Posted: Sat Jul 01, 2006 9:15 pm Post subject: Re: Newbie question - RGB function |
|
|
All I can see listed as being in the windows unit is:
TOwnerDrawState
TPoint
TRect
TSize
TSmallPoint
Routines
Beep
DeleteFile
EqualRect
FindClose
GetCursorPos
GetFileType
GetLastError
GetModuleFileName
InterlockedDecrement
InterlockedExchange
InterlockedExchangeAdd
InterlockedIncrement
IntersectRect
IsRectEmpty
MulDiv
OffsetRect
PtInRect
RegisterClass
Sleep
UnionRect
UnregisterClass
None of these seem to do what RGB is described to do in the .net SDK
If I just remove (or rather comment it out)
"
function RGB(red,green,blue:byte):longword; external 'gdi32.dll';
"
then the when the show button is clicked nothing happens. "windows" is
listed in the uses clause.
Do you think that this could be the case of the function not being
included in the personal version?
| Quote: |
"Tim H" <xxx (AT) xxx (DOT) co.uk> skrev i en meddelelse
news:44a689db (AT) newsgroups (DOT) borland.com...
I'm trying to use the RGB function.
Imported with:
function RGB(red,green,blue:byte):longword; external 'gdi32.dll';
Error:
" Unable to find an entry point named RGB in DLL gdi32.dll. "
There is no need to import RGB.
And it's not defined in gdi32, it's a macro, which means you can't
import
it. That might explain the error.
There already is a RGB function in the Windows unit, just use that.
--
Finn Tolderlund
http://www.tolderlund.eu/delphi/
|
--- posted by geoForum on http://delphi.newswhat.com |
|
| Back to top |
|
 |
Finn Tolderlund Guest
|
Posted: Sat Jul 01, 2006 9:16 pm Post subject: Re: Newbie question - RGB function |
|
|
"Tim H" <xxx (AT) xxx (DOT) co.uk> skrev i en meddelelse
news:44a693bd$1 (AT) newsgroups (DOT) borland.com...
| Quote: | All I can see listed as being in the windows unit is:
None of these seem to do what RGB is described to do in the .net SDK
If I just remove (or rather comment it out)
function RGB(red,green,blue:byte):longword; external 'gdi32.dll';
then the when the show button is clicked nothing happens. "windows" is
listed in the uses clause.
Do you think that this could be the case of the function not being
included in the personal version?
|
Sorry, but you are not thinking straight right now
When you remove your own RGB and your app still can compile it means that
the compiler has found the RGB function.
Right? Right!
Now, since nothing apparently happens when you click the button, you have to
take a closer look at your button click code.
--
Finn Tolderlund
http://www.tolderlund.eu/delphi/ |
|
| Back to top |
|
 |
Finn Tolderlund Guest
|
Posted: Sun Jul 02, 2006 3:20 am Post subject: Re: Newbie question - RGB function |
|
|
"Tim H" <xxx (AT) xxx (DOT) co.uk> skrev i en meddelelse
news:44a6ecb5$1 (AT) newsgroups (DOT) borland.com...
| Quote: | please excuse my ignorance (I realise there is probably a really simple
answer but I just cant get it to work.) My current code is as follows:
procedure TFrmMyColourCreater.BtnShowClick(Sender: TObject);
var rectangle: TRect;
begin
//rectangle:=paintbox1.;
//paintbox1.Color:= rgb(strtoint(EdtRed.Text),strtoint
(EdtGreen.Text),strtoint(EdtBlue.Text));
paintbox1.canvas.Brush.Color:= rgb(strtoint(EdtRed.Text),strtoint
(EdtGreen.Text),strtoint(EdtBlue.Text));
paintbox1.Canvas.Brush.Style:= bsclear;
paintbox1.canvas.FillRect(bounds
(paintbox1.Left,paintbox1.Top,paintbox1.Width,paintbox1.Height));
end;
|
First, as the help for TPaintBox says:
========
Use TPaintBox to add custom images to a form. Unlike TImage, which displays
an image that is stored in a bitmap, icon, or metafile, TPaintBox requires
an application to draw the image directly on a canvas. Use the OnPaint event
handler to draw on the paint box's Canvas, the drawing surface of the paint
box.
========
Note the bit that says: "Use the OnPaint event handler".
Second, change your code as follows:
Delete this line
paintbox1.Canvas.Brush.Style:= bsclear;
Or use bsSolid instead of bsClear;
And instead of
paintbox1.canvas.FillRect(bounds(paintbox1.Left,paintbox1.Top,paintbox1.Width,paintbox1.Height));
use this:
paintbox1.canvas.FillRect(bounds(0,0,paintbox1.Width,paintbox1.Height));
--
Finn Tolderlund
http://www.tolderlund.eu/delphi/ |
|
| Back to top |
|
 |
Tim H Guest
|
Posted: Sun Jul 02, 2006 3:35 am Post subject: Re: Newbie question - RGB function |
|
|
please excuse my ignorance (I realise there is probably a really simple
answer but I just cant get it to work.) My current code is as follows:
procedure TFrmMyColourCreater.BtnShowClick(Sender: TObject);
var rectangle: TRect;
begin
//rectangle:=paintbox1.;
//paintbox1.Color:= rgb(strtoint(EdtRed.Text),strtoint
(EdtGreen.Text),strtoint(EdtBlue.Text));
paintbox1.canvas.Brush.Color:= rgb(strtoint(EdtRed.Text),strtoint
(EdtGreen.Text),strtoint(EdtBlue.Text));
paintbox1.Canvas.Brush.Style:= bsclear;
paintbox1.canvas.FillRect(bounds
(paintbox1.Left,paintbox1.Top,paintbox1.Width,paintbox1.Height));
end;
types is in the uses clause as well as the things that are added
automatically. I dont see why paintbox1.color doesn't work but figured
that was the error but I cant seem to get it to work the other way i've
tried either.
Again, any help much appreciated. I think that I may have tried this
before and that being why I thought it was something to do with rgb but
i guess that its actually much simpler i just cant seem to figure what.
Tim H
| Quote: |
"Tim H" <xxx (AT) xxx (DOT) co.uk> skrev i en meddelelse
news:44a693bd$1 (AT) newsgroups (DOT) borland.com...
All I can see listed as being in the windows unit is:
None of these seem to do what RGB is described to do in the .net SDK
If I just remove (or rather comment it out)
function RGB(red,green,blue:byte):longword; external 'gdi32.dll';
then the when the show button is clicked nothing happens. "windows" is
listed in the uses clause.
Do you think that this could be the case of the function not being
included in the personal version?
Sorry, but you are not thinking straight right now
When you remove your own RGB and your app still can compile it means
that
the compiler has found the RGB function.
Right? Right!
Now, since nothing apparently happens when you click the button, you
have to
take a closer look at your button click code.
--
Finn Tolderlund
http://www.tolderlund.eu/delphi/
|
--- posted by geoForum on http://delphi.newswhat.com |
|
| Back to top |
|
 |
Tim H Guest
|
Posted: Sun Jul 02, 2006 4:47 am Post subject: Re: Newbie question - RGB function |
|
|
| Quote: |
"Tim H" <xxx (AT) xxx (DOT) co.uk> skrev i en meddelelse
news:44a6ecb5$1 (AT) newsgroups (DOT) borland.com...
please excuse my ignorance (I realise there is probably a really
simple
answer but I just cant get it to work.) My current code is as follows:
procedure TFrmMyColourCreater.BtnShowClick(Sender: TObject);
var rectangle: TRect;
begin
//rectangle:=paintbox1.;
//paintbox1.Color:= rgb(strtoint(EdtRed.Text),strtoint
(EdtGreen.Text),strtoint(EdtBlue.Text));
paintbox1.canvas.Brush.Color:= rgb(strtoint(EdtRed.Text),strtoint
(EdtGreen.Text),strtoint(EdtBlue.Text));
paintbox1.Canvas.Brush.Style:= bsclear;
paintbox1.canvas.FillRect(bounds
(paintbox1.Left,paintbox1.Top,paintbox1.Width,paintbox1.Height));
end;
First, as the help for TPaintBox says:
========
Use TPaintBox to add custom images to a form. Unlike TImage, which
displays
an image that is stored in a bitmap, icon, or metafile, TPaintBox
requires
an application to draw the image directly on a canvas. Use the OnPaint
event
handler to draw on the paint box's Canvas, the drawing surface of the
paint
box.
========
Note the bit that says: "Use the OnPaint event handler".
Second, change your code as follows:
Delete this line
paintbox1.Canvas.Brush.Style:= bsclear;
Or use bsSolid instead of bsClear;
And instead of
paintbox1.canvas.FillRect(bounds
(paintbox1.Left,paintbox1.Top,paintbox1.Width,paintbox1.Height));
use this:
paintbox1.canvas.FillRect(bounds
(0,0,paintbox1.Width,paintbox1.Height));
--
Finn Tolderlund
http://www.tolderlund.eu/delphi/
Thanks I've got it now. |
--- posted by geoForum on http://delphi.newswhat.com |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|