Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "KOL";
Текущий архив: 2005.09.11;
Скачать: [xml.tar.bz2];

Вниз

Bitmap.LoadFromResourceName   Найти похожие ветки 

 
Boguslaw   (2005-01-25 18:09) [0]

Bitmap.LoadFromResourceName(hInstance,"INFO");

(in balloon.rc:

INFO BITMAP "images\info.bmp"

)

not working in KOL 2.05

Bitmap.LoadFromFile(GetStartDir + "images\info.bmp");
working good

What"s going on ? INFO resource is not found ? If I GEtLastError after this function error will be shown ?


 
thaddy   (2005-01-25 18:17) [1]

"images\.info.bmp '  ??? typo or: "imgages\.info.bmp" ?


 
thaddy   (2005-01-25 18:18) [2]

There's a space in the name and the quotes are not equal type


 
Boguslaw   (2005-01-25 18:20) [3]

Sorry. I see no typo error ! Below is my full code (just a little Balloon window ) and here You are balloon.rc:

ERROR BITMAP "error.bmp"
INFO BITMAP "info.bmp"
WARNING BITMAP "warning.b

My code : (could be usefull ;-)

{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
unit Unit1;

interface

{$IFDEF KOL_MCK}
uses Windows, Messages, ShellAPI, KOL {$IFNDEF KOL_MCK}, mirror, Classes, Controls, mckControls, mckObjs, Graphics,  mckCtrls,  mckSPLPicture, StdCtrls {$ENDIF};
{$ELSE}
{$I uses.inc}
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
{$ENDIF}

type
 {$IFDEF KOL_MCK}
{$I MCKfakeClasses.inc}
 {$IFDEF KOLCLASSES} TfrmBalloon = class; PfrmBalloon = TfrmBalloon; {$ELSE OBJECTS} PfrmBalloon = ^TfrmBalloon; {$ENDIF CLASSES/OBJECTS}
 {$IFDEF KOLCLASSES}{$I TfrmBalloon.inc}{$ELSE} TfrmBalloon = object(TObj) {$ENDIF}
 Form: PControl;
{$ELSE not_KOL_MCK}
 TfrmBalloon = class(TForm)
{$ENDIF KOL_MCK}
 KOLProject1: TKOLProject;
 KOLForm1: TKOLForm;
 lblTitle: TKOLLabel;
 TM: TKOLTimer;
 lblText: TKOLLabel;
   PB: TKOLPaintBox;
 procedure TMTimer(Sender: PObj);
   procedure KOLForm1FormCreate(Sender: PObj);
   procedure KOLForm1Destroy(Sender: PObj);
   procedure PBPaint(Sender: PControl; DC: HDC);
private
 { Private declarations }
Bitmap : PBitmap;
procedure ShowBalloonInternal(blnLeft, blnTop: Integer; blnTitle, blnText: String;bKind : Integer; blnDuration: Integer);
public
 { Public declarations }
end;

var
 frmBalloon {$IFDEF KOL_MCK} : PfrmBalloon {$ELSE} : TfrmBalloon {$ENDIF} ;

{$IFDEF KOL_MCK}
procedure NewfrmBalloon( var Result: PfrmBalloon; AParent: PControl );
{$ENDIF}

procedure ShowBalloon(blnLeft, blnTop: Integer; blnTitle, blnText: String;bKind : Integer; blnDuration: Integer);

implementation

{$IFNDEF KOL_MCK} {$R *.DFM} {$ENDIF}

{$IFDEF KOL_MCK}
{$I Unit1_1.inc}
{$ENDIF}

procedure Label2Paint(Sender: PControl);
var
OldFnt: HFONT;
R: TRect;
H: Integer;
DC: HDC;
begin
DC := Sender.Canvas.Handle;
OldFnt := SelectObject(DC,Sender.Font.Handle);
SetBkMode(DC,TRANSPARENT);
R := Sender.ClientRect;
SetTextColor(DC,Sender.Font.Color);
H := DrawText(DC,@Sender.Caption[1],Length(Sender.Caption),R,DT_CENTER or DT_WORDBREAK or DT_CALCRECT);
if H <> (Sender.Height+3) then Sender.Height := H+3; //
DrawText(DC,@Sender.Caption[1],Length(Sender.Caption),R,DT_CENTER or DT_WORDBREAK);
SelectObject(DC,OldFnt);
end;

procedure ShowBalloon(blnLeft, blnTop: Integer; blnTitle, blnText: String;bKind : Integer; blnDuration: Integer);
var
Balloon : PfrmBalloon;
begin
NewfrmBalloon(Balloon,nil);
Balloon.ShowBalloonInternal(blnLeft,blnTop,blnTitle,blnText,bKind,blnDuration);
Balloon.Form.Free;
end;

//ShowBalloon(Screen.Width-Form1.Width-5,Screen.Height-10,"Test Balloon!","To jest test bardzo d&#322;ugi i bardzo ci&#261;gn&#261;cy" + #13#10 + " si&#281; na nie wiem co i co by tu dalej",1000);
procedure TfrmBalloon.ShowBalloonInternal(blnLeft, blnTop: Integer; blnTitle, blnText: String;bKind : Integer; blnDuration: Integer);
Var
ArrowHeight, ArrowWidth: Integer;
FormRegion, ArrowRegion: HRGN;
Arrow: Array [0..2] Of TPoint;
Size : tagSIZE;
S : string;
Begin
ArrowHeight := 20;
ArrowWidth  := 20;

lblTitle.Caption := blnTitle;

lblText.Top     := lblTitle.Top + lblTitle.Height + 8;

{
with lblText^ do begin
s := Format("BoundRect=(%d,%d,%d,%d),ClientRect=(%d,%d,%d,%d)",[BoundsRect.Left,BoundsRect.Top,BoundsRect.Right,BoundsRect.Bo ttom,
ClientRect.Left,ClientRect.Top,ClientRect.Right,ClientRect.Bottom]);
end;
MsgOk(s);

with lblText^ do begin
s := Format("BoundRect=(%d,%d,%d,%d),ClientRect=(%d,%d,%d,%d)",[BoundsRect.Left,BoundsRect.Top,BoundsRect.Right,BoundsRect.Bo ttom,
ClientRect.Left,ClientRect.Top,ClientRect.Right,ClientRect.Bottom]);
end;
MsgOk(s);

}
case bKind of
 0 : Bitmap.LoadFromFile(GetStartDir + "images\info.bmp");//ResourceName(hInstance,"INFO");
 1 : Bitmap.LoadFromResourceName(hInstance,"WARNING");
 2 : Bitmap.LoadFromResourceName(hInstance,"ERROR");
end;

if bKind in [1,2] then MessageBeep(MB_ICONHAND);
 lblText.Caption := blnText;
Label2Paint(lblText);
  Form.ClientHeight := lblText.Top + lblText.Height + 10 + ArrowHeight;
 //  Form.ClientWidth :=  lblText.Width - lblText.Left -10 -ArrowWidth;

If (lblTitle.Left + lblTitle.Width) > (lblText.Left + lblText.Width) Then
 Form.Width := lblTitle.Left + lblTitle.Width + 10
else
 Form.Width := lblText.Left + lblText.Width + 10;

 Form.Left := blnLeft - (Form.Width - 20);
 Form.Top  := blnTop - (Form.Height);

  FormRegion := CreateRoundRectRgn(0, 0, Form.Width, Form.Height - (ArrowHeight - 2), 7, 7);

 Arrow[0] := MakePoint(Form.Width - ArrowWidth - 20, Form.Height - ArrowHeight);
 Arrow[1] := MakePoint(Form.Width - 20, Form.Height);
 Arrow[2] := MakePoint(Form.Width - 20, Form.Height - ArrowHeight);

ArrowRegion := CreatePolygonRgn(Arrow, 3, WINDING);

CombineRgn(FormRegion, FormRegion, ArrowRegion, RGN_OR);
DeleteObject(ArrowRegion);
SetWindowRgn(Form.Handle, FormRegion, True);


TM.Interval := blnDuration;
TM.Enabled := true;
// Form.ShowModal;
end;

procedure TfrmBalloon.TMTimer(Sender: PObj);
begin
Form.Close;
end;

procedure TfrmBalloon.KOLForm1FormCreate(Sender: PObj);
var
s : String;
begin
Bitmap := NewDIBBitmap(0,0,pfDevice);
s := "sdfsdf" + #13#10 + "TEst2" + #13#10 + "A to jest super d&#322;ugi tekst kt&#243;ry musi si&#281; zmie&#347;ci&#263; tutaj" + #13#10 + "I ostatnia linia";
ShowBalloonInternal(ScreenWidth-50,ScreenHeight-25,"Balloon!",s,2,5000);
//s := "sdfsdf asd asd asd as dA to jest super d&#322;ugi tekst kt&#243;ry musi si&#281; zmie&#347;ci&#263; tutaj" + #13#10 + "I ostatnia linia";
//ShowBalloonInternal(ScreenWidth-50,ScreenHeight-25,"Balloon!",s,0,5000);
//s := "Koniec test&#243;w!";
//ShowBalloonInternal(400,400,"Balloon!",s,2,5000);
end;

procedure TfrmBalloon.KOLForm1Destroy(Sender: PObj);
begin
Bitmap.Free;
end;

procedure TfrmBalloon.PBPaint(Sender: PControl; DC: HDC);
begin
Bitmap.Draw(DC,0,0);
end;

end.


 
Владимир Кладов   (2005-01-25 20:15) [4]

see no {$R ...} directive. Where are my glasses?..


 
Boguslaw   (2005-01-26 14:10) [5]

Thank You. Now is working. :-)
Strange, becouse I added ballon.rc to project and I was sure that ballon.res should be included automatically.
I"m glad to say that KOL will be probably used for creating GUI for GPL on-access antivirus scanner based on Clam antivirus www.clamav.net
Anybody with assembler knowledge is invited to help develop this innovative project (it could be the first Windows resident antivirus protection Open Source and GPL,beside ClamWin)
I hope Vladimir that You will find a little time to help fix bugs in KOL GUI ? I will notify about progress.

Best Regards
Boguslaw Brandys



Страницы: 1 вся ветка

Форум: "KOL";
Текущий архив: 2005.09.11;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.47 MB
Время: 0.01 c
3-1122621347
-=snoop=-
2005-07-29 11:15
2005.09.11
отображение в TDBgrid


1-1124684699
Демидрол
2005-08-22 08:24
2005.09.11
Не стандартный MainMenu


2-1123529338
Nox777
2005-08-08 23:28
2005.09.11
Edit только для цифр?


14-1124199196
Vlad Oshin
2005-08-16 17:33
2005.09.11
Как думаете, кто глючит: принтер или FastReport?


1-1124284424
zorik
2005-08-17 17:13
2005.09.11
Аналог кнопки "Выполнить" в Windows (как организовать)





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский