Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

Lazarus IDE and 组件 下载地址版权申明
查看: 4620|回复: 1

急切的询问,如何在kol_ce的窗体上面绘制位图文件,需要代码

[复制链接]

该用户从未签到

发表于 2009-9-13 12:09:25 | 显示全部楼层 |阅读模式
最近在搞WinCE的游戏,但是不知道如何能够打开一个位图,然后绘制到屏幕上,有知道的大侠请留言,谢谢了
我看了一些Lazarus kol的代码,如下,但是在ce上面没有反应,请各位帮帮忙,谢谢了


program KolBitmapDemo;

{$DEFINE UNICODE_CTRLS}
uses
Windows,
  Messages,
  Kol;


var
  //Applet,                {A main form or application}
  PaintBox:pControl;       {A simple static paintbox}
  Bit:pBitmap;          {A bitmap}
  Dialog:pOpenSaveDialog;  {Our FileOpen Dialog}
  Menu:pMenu;              {And a menu}
  //Bitmap2:pBitmap;
{
This handles the OnPaint event from the Paintbox
It draws the bitmap on the PaintBox's Canvas}

procedure paint(dummy:pointer;sender:pcontrol;DC:HDC);
//var Rect:Trect;
begin
  Bit.Draw(DC,0,0);
end;

{This handles the Menuclicks}
procedure MenuClick(dummy:pointer;sender:pmenu;Item:integer);
begin
  begin
    case item of
    1:begin
//        Dialog.execute;
//        Bit.Clear;
//        if Trim(Dialog.Filename)<> '' then
//        begin
//          {We have selected a file, Load it}
//          Bit.LoadFromFile(Dialog.Filename);
//          Applet.SimplestatusText:=ExtractFileNameWOExt(Dialog.Filename);
//          {Do some housekeeping}
//          PaintBox.Width:=BitMap.Width;
//          PaintBox.Height:=Bitmap.Height;
//          Applet.ClientHeight:=Bitmap.Height + Applet.Border * 2;//Resizeparent doesnot work
//        end;
      end;
    3:begin
        {Create simplest aboutbox}
        MsgOk('Kol Bitmap Viewer Demo'+
        #13#10+
        #13#10+
        'Does not support all palettes,'+
        #13#10+
        'so it may not always look good'+
        #13#10+
        #13#10+
        '(c)2001, Thaddy de Koning');
      end;
    end;
  end;
end;

begin
  {Create a form and set some defaults}
  Applet:=NewForm(Nil,'Kol Bitmap Viewer Demo').SetSize(400,250);
  Applet.CenterOnParent;
  {Create a statusbar to display filenames}
  Applet.SimplestatusText:='';

  {Create a FileOpen Dialog}
  Dialog:=NewOpenSaveDialog('Image','',[]);
  Dialog.Filename:='';
  Dialog.Filter:='Bitmap files|*.bmp';

  {Create a menu with just one item:File}
  {Menu:=}NewMenu(Applet,0,['&File','(','&Open',')','&Help','(','&About',')',''],TonMenuItem(MakeMethod(nil,@MenuClick)));

  {Create the Paintbox to draw the bitmap on}
  PaintBox:=NewPaintbox(Applet).setalign(caClient);
  PaintBox.OnPaint:=TOnPaint(MakeMethod(nil,@Paint));
  Paintbox.Transparent:=true;

  {Create the bitmap itself}
  Bit:=NewBitMap(0,0);

  {Show some 'Art' by Thaddy de Koning}
  If FileExists('Kol.bmp')
    then Bit.LoadfromFile('Kol.bmp');

  {Run our application}
  Run(Applet);

  {Free the bitmap:it has no parent}
  Bit.free;
  {Free the dialog:it has no parent}
  Dialog.free;
end.
回复

使用道具 举报

该用户从未签到

发表于 2009-9-13 17:37:23 | 显示全部楼层
我也想知道,原来的方法无效
回复 支持 反对

使用道具 举报

*滑块验证:

本版积分规则

QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

GMT+8, 2025-5-2 22:32 , Processed in 0.026402 second(s), 10 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表