Salve,
ho qualche problema a visualizzare una bitmap su una finestra MDI.
Sbaglio forse qualcosa nell'utilizzare la funzione drawbitmap ?
Grazie
Marco
----
#include "FiveWin.ch"
#define SRCPAINT 15597702 // 0xEE0086
#define SRCAND 8913094
static oWnd
//----------------------------------------------------------------------------//
function Main()
DEFINE WINDOW oWnd TITLE "Testing bitmaps";
MDI
@ 2, 2 BUTTON "&Display bitmap" SIZE 120, 25 ACTION SHOWBMP(OWND) OF OWND:OWNDCLIENT
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//
function ShowBmp( oDlg )
local oBmp1
DEFINE BITMAP oBmp1 FILENAME "..\bitmaps\Cartoon.bmp"
DrawBitmap( oWnd:oWndClient, oBmp1:hBitmap, 0, 0, 0, 0, SRCPAINT )
oBmp1:End()
return nil
Visualizzare una bitmat su oWnd:oWndClient
Moderator: Enrico Maria Giordano
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
A me funziona in questo modo:
ciao
Code: Select all
STATIC oBitmap, MainWnd
********
FUNCTION Main()
********
DEFINE WINDOW MainWnd FROM 0,0 to 28,80 ;
TITLE "";
ICON oIcon;
COLOR CLR_WHITE, oV:nRGBSfondo;
MENU oMenu;
MENUINFO 5;
MDI // Finestra MDI
@MainWnd:nBottom,MainWnd:nRight BITMAP oBitMap NAME "LOGO2_WP50" OF MainWnd:oWndClient PIXEL
ACTIVATE WINDOW MainWnd MAXIMIZED ;
ON RESIZE ( Muevo(), oBitMap:refresh() )
RETURN NIL
*
** eof Main
***************
STATIC FUNCTION Muevo()
***************
local aRect := MainWnd:GetCliRect()
local oRect := TRect():New( aRect:nTop, aRect:nLeft, aRect:nBottom,;
aRect:nRight )
oRect:nTop := Max( 0, Int( ( aRect:nBottom - oBitMap:nHeight * 2 - 10 ) ) )
oRect:nBottom := oRect:nTop + oBitMap:nHeight - 1
oRect:nLeft := Max( 0, Int( ( aRect:nRight - oBitMap:nWidth - 10 ) ) )
oRect:nRight := oRect:nLeft + oBitmap:nWidth - 1
oBitMap:SetCoors( oRect )
return nil
*
** eof Muevo()
ciao
Pedro Gonzalez
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Visualizzare una bitmat su oWnd:oWndClient
Code: Select all
function ShowBmp( oDlg )
local oBmp1
DEFINE BITMAP oBmp1 FILENAME "\fwharbour\bitmaps\Cartoon.bmp"
DrawBitmap( oWnd:oWndClient:GetDC(), oBmp1:hBitmap, 0, 0, 0, 0, SRCPAINT )
oWnd:oWndClient:ReleaseDC()
oBmp1:End()
return nil
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
Si, è quello che volevo. Grazie.
Un chiarimento però:
considerato che devo visualizzare diverse bitmap, inserisco oWnd:oWndClient:GetDC() in una variabile, lo utilizzo per tutte le bitmap richieste e quindi faccio un ReleaseDC alla fine. E' corretto o agendo così creo perdite di risorse ?
Esempio:
function ShowBmp( oDlg )
local oBmp1,oDc
oDc:=oWnd:oWndClient:GetDC()
DEFINE BITMAP oBmp1 RESOURCE "IMAGE1"
DrawBitmap( oDC, oBmp1:hBitmap, 0, 0, 0, 0, SRCPAINT )
oBmp1:End()
DEFINE BITMAP oBmp1 RESOURCE "IMAGE2"
DrawBitmap( oDC, oBmp1:hBitmap, 0, 0, 0, 0, SRCPAINT )
oBmp1:End()
DEFINE BITMAP oBmp1 RESOURCE "IMAGE3"
DrawBitmap( oDC, oBmp1:hBitmap, 0, 0, 0, 0, SRCPAINT )
oBmp1:End()
oWnd:oWndClient:ReleaseDC()
return nil
Un chiarimento però:
considerato che devo visualizzare diverse bitmap, inserisco oWnd:oWndClient:GetDC() in una variabile, lo utilizzo per tutte le bitmap richieste e quindi faccio un ReleaseDC alla fine. E' corretto o agendo così creo perdite di risorse ?
Esempio:
function ShowBmp( oDlg )
local oBmp1,oDc
oDc:=oWnd:oWndClient:GetDC()
DEFINE BITMAP oBmp1 RESOURCE "IMAGE1"
DrawBitmap( oDC, oBmp1:hBitmap, 0, 0, 0, 0, SRCPAINT )
oBmp1:End()
DEFINE BITMAP oBmp1 RESOURCE "IMAGE2"
DrawBitmap( oDC, oBmp1:hBitmap, 0, 0, 0, 0, SRCPAINT )
oBmp1:End()
DEFINE BITMAP oBmp1 RESOURCE "IMAGE3"
DrawBitmap( oDC, oBmp1:hBitmap, 0, 0, 0, 0, SRCPAINT )
oBmp1:End()
oWnd:oWndClient:ReleaseDC()
return nil
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact: