Dear gentlemen, I can not find what I´m doing wrong. I can not compile it in IDE of Hmg.3.0.39:
Code: Select all
/*
Source code name: Demo3.prg
Author..........: Mr. Grigory Filatov
Contributions...: Mr. Ciro Vargas Clemov
Adaptations.....: Pablo César Arrascaeta
*/
#include "minigui.ch"
Function Main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 ;
HEIGHT 480 ;
TITLE 'Hello World!' ;
MAIN
DEFINE BUTTON Button_1
ROW 10
COL 30
WIDTH 280
HEIGHT 26
ACTION {||TaskBarPos ()}
CAPTION "Task Bar Position"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
HELPID Nil
FLAT .F.
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
MULTILINE .F.
PICTURE NIL
PICTALIGNMENT LEFT
END BUTTON
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil
Static Function TaskBarPos ()
Local aPos := GetTaskBarPosition()
MsgInfo( ;
"TOP="+str(aPos[1],4)+Chr(13)+Chr(10)+ ;
"LEFT="+str(aPos[2],4)+Chr(13)+Chr(10)+ ;
"BOTTOM="+str(aPos[3],4)+Chr(13)+Chr(10)+ ;
"RIGHT="+str(aPos[4],4) )
SAVEWINDOW( "Form_1" , "Teste.bmp" , aPos[1] , aPos[2] , aPos[3] , aPos[4] )
Return Nil
FUNCTION SAVEWINDOW( cWindowName , cFileName , nRow , nCol , nWidth , nHeight )
Local ntop , nleft , nbottom , nright
if valtype ( cFileName ) = 'U'
cFileName := GetStartupFolder() + '\' + cWindowName + '.bmp'
endif
if valtype ( nRow ) = 'U' ;
.or. ;
valtype ( nCol ) = 'U' ;
.or. ;
valtype ( nWidth ) = 'U' ;
.or. ;
valtype ( nHeight ) = 'U'
ntop := -1
nleft := -1
nbottom := -1
nright := -1
else
ntop := nRow
nleft := nCol
nbottom := nHeight + nRow
nright := nWidth + nCol
endif
SAVEWINDOWBYHANDLE ( GetFormHandle ( cWindowName ) , cFileName , ntop , nleft , nbottom , nright )
RETURN NIL
FUNCTION PRINTWINDOW ( cWindowName , lPreview , ldialog , nRow , nCol , nWidth , nHeight )
LOCAL lSuccess
LOCAL TempName
LOCAL W
LOCAL H
LOCAL HO
LOCAL VO
LOCAL bw , bh , r , tw , th , dc , wdif , hdif , dr
LOCAL ntop , nleft , nbottom , nright
memvar _hmg_printer_name
memvar _hmg_printer_aprinterproperties
memvar _hmg_printer_preview
memvar _hmg_printer_timestamp
memvar _hmg_printer_hdc_bak
memvar _hmg_printer_pagecount
memvar _hmg_printer_copies
memvar _hmg_printer_collate
memvar _hmg_printer_hdc
memvar _hmg_printer_JobName
if valtype ( nRow ) = 'U' ;
.or. ;
valtype ( nCol ) = 'U' ;
.or. ;
valtype ( nWidth ) = 'U' ;
.or. ;
valtype ( nHeight ) = 'U'
ntop := -1
nleft := -1
nbottom := -1
nright := -1
else
ntop := nRow
nleft := nCol
nbottom := nHeight + nRow
nright := nWidth + nCol
endif
if ValType ( lDialog ) = 'U'
lDialog := .F.
endif
if ValType ( lPreview ) = 'U'
lPreview := .F.
endif
if lDialog
IF lPreview
SELECT PRINTER DIALOG TO lSuccess PREVIEW
ELSE
SELECT PRINTER DIALOG TO lSuccess
ENDIF
IF ! lSuccess
RETURN NIL
ENDIF
else
IF lPreview
SELECT PRINTER DEFAULT TO lSuccess PREVIEW
ELSE
SELECT PRINTER DEFAULT TO lSuccess
ENDIF
IF ! lSuccess
MSGMINIGUIERROR ( "Can't Init Printer" )
RETURN NIL
ENDIF
endif
IF ! _IsWIndowDefined ( cWindowName )
MSGMINIGUIERROR ( 'Window Not Defined' )
RETURN NIL
ENDIF
TempName := GetTempFolder() + '\_hmg_printwindow_' + alltrim(str(int(seconds()*100))) + '.bmp'
SAVEWINDOWBYHANDLE ( GetFormHandle ( cWindowName ) , TempName , ntop , nleft , nbottom , nright )
HO := GETPRINTABLEAREAHORIZONTALOFFSET()
VO := GETPRINTABLEAREAVERTICALOFFSET()
W := GETPRINTABLEAREAWIDTH() - 10 - ( HO * 2 )
H := GETPRINTABLEAREAHEIGHT() - 10 - ( VO * 2 )
if ntop = -1
bw := GetProperty ( cWindowName , 'Width' )
bh := GetProperty ( cWindowName , 'Height' ) - GetTitleHeight ( GetFormHandle (cWindowName) )
else
bw := nright - nleft
bh := nbottom - ntop
endif
r := bw / bh
tw := 0
th := 0
do while .t.
tw ++
th := tw / r
if tw > w .or. th > h
exit
endif
enddo
wdif := w - tw
if wdif > 0
dc := wdif / 2
else
dc := 0
endif
hdif := h - th
if hdif > 0
dr := hdif / 2
else
dr := 0
endif
START PRINTDOC
START PRINTPAGE
@ VO + 10 + ( ( h - th ) / 2 ) , HO + 10 + ( ( w - tw ) / 2 ) PRINT IMAGE TempName WIDTH tW HEIGHT tH
END PRINTPAGE
END PRINTDOC
DO EVENTS
Ferase(TempName)
RETURN NIL
#pragma BEGINDUMP
#define HB_OS_WIN_32_USED
#define _WIN32_WINNT 0x0400
#include <shlobj.h>
#include <windows.h>
#include <winuser.h>
#include <wingdi.h>
#include "hbapi.h"
#include "hbvm.h"
#include "hbstack.h"
#include "hbapiitm.h"
#include "commctrl.h"
///////////////////////////////////////////////////////////////////////////////
// SAVE WINDOW (Based On Code Contributed by Ciro Vargas Clemov)
///////////////////////////////////////////////////////////////////////////////
HANDLE ChangeBmpFormat(HBITMAP , HPALETTE );
WORD GetDIBColors(LPSTR lpDIB) ;
HB_FUNC( SAVEWINDOWBYHANDLE )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
HDC hDC = GetDC( hWnd );
HDC hMemDC ;
RECT rc ;
HBITMAP hBitmap ;
HBITMAP hOldBmp ;
HPALETTE hPal;
LPSTR File = hb_parc(2) ;
HANDLE hDIB ;
int top = hb_parni(3) ;
int left = hb_parni(4) ;
int bottom = hb_parni(5) ;
int right = hb_parni(6) ;
BITMAPFILEHEADER bmfHdr ;
LPBITMAPINFOHEADER lpBI ;
HANDLE filehandle ;
DWORD dwDIBSize ;
DWORD dwWritten ;
DWORD dwBmBitsSize ;
if ( top != -1 && left != -1 && bottom != -1 && right != -1 )
{
rc.top = top ;
rc.left = left ;
rc.bottom = bottom ;
rc.right = right ;
}
else
{
GetClientRect( hWnd, &rc );
}
hMemDC = CreateCompatibleDC( hDC );
hBitmap = CreateCompatibleBitmap( hDC, rc.right-rc.left, rc.bottom-rc.top );
hOldBmp = ( HBITMAP ) SelectObject( hMemDC, hBitmap );
BitBlt( hMemDC, 0, 0 , rc.right-rc.left, rc.bottom-rc.top, hDC, rc.top, rc.left, SRCCOPY );
SelectObject( hMemDC, hOldBmp );
hDIB = ChangeBmpFormat(hBitmap ,hPal);
filehandle = CreateFile( File , GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
lpBI = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
if (!lpBI)
{
CloseHandle(filehandle);
return;
}
if (lpBI->biSize != sizeof(BITMAPINFOHEADER))
{
GlobalUnlock(hDIB);
CloseHandle(filehandle);
return;
}
bmfHdr.bfType = ((WORD) ('M' << 8) | 'B');
dwDIBSize = *(LPDWORD)lpBI + ( GetDIBColors( (LPSTR) lpBI ) * sizeof(RGBTRIPLE)) ;
dwBmBitsSize = ((((lpBI->biWidth)*((DWORD)lpBI->biBitCount))+ 31) / 32 * 4) * lpBI->biHeight;
dwDIBSize += dwBmBitsSize;
lpBI->biSizeImage = dwBmBitsSize;
bmfHdr.bfSize = dwDIBSize + sizeof(BITMAPFILEHEADER);
bmfHdr.bfReserved1 = 0;
bmfHdr.bfReserved2 = 0;
bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + lpBI->biSize + ( GetDIBColors( (LPSTR) lpBI ) * sizeof(RGBTRIPLE)) ;
WriteFile(filehandle, (LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER), &dwWritten, NULL);
WriteFile(filehandle, (LPSTR)lpBI, dwDIBSize, &dwWritten, NULL);
GlobalUnlock(hDIB);
CloseHandle(filehandle);
DeleteDC( hMemDC );
GlobalFree (hDIB);
ReleaseDC( hWnd, hDC );
}
HANDLE ChangeBmpFormat(HBITMAP hBitmap, HPALETTE hPal)
{
BITMAP bm;
BITMAPINFOHEADER bi;
LPBITMAPINFOHEADER lpbi;
DWORD dwLen;
HGLOBAL hDIB;
HGLOBAL h;
HDC hDC;
WORD biBits;
if (!hBitmap)
{
return 0 ;
}
if (!GetObject(hBitmap, sizeof(bm), (LPSTR)&bm))
{
return 0 ;
}
if ( hPal == 0 )
{
hPal = GetStockObject(DEFAULT_PALETTE);
}
biBits = bm.bmPlanes * bm.bmBitsPixel ;
if (biBits <= 1)
{
biBits = 1;
}
else if (biBits <= 4)
{
biBits = 4;
}
else if (biBits <= 8)
{
biBits = 8;
}
else
{
biBits = 24;
}
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = bm.bmWidth;
bi.biHeight = bm.bmHeight;
bi.biPlanes = 1;
bi.biBitCount = biBits;
bi.biCompression = BI_RGB;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
dwLen = bi.biSize + ( GetDIBColors( (LPSTR)&bi ) * sizeof ( RGBTRIPLE ) ) ;
hDC = GetDC(NULL);
hPal = SelectPalette(hDC, hPal, FALSE);
RealizePalette(hDC);
hDIB = GlobalAlloc(GHND, dwLen);
if (!hDIB)
{
SelectPalette(hDC, hPal, TRUE);
RealizePalette(hDC);
ReleaseDC(NULL, hDC);
return 0;
}
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
*lpbi = bi;
GetDIBits(hDC, hBitmap, 0, (UINT)bi.biHeight, NULL, (LPBITMAPINFO)lpbi,DIB_RGB_COLORS);
bi = *lpbi;
GlobalUnlock(hDIB);
if (bi.biSizeImage == 0)
{
bi.biSizeImage = ((((DWORD)bm.bmWidth * biBits)+ 31) / 32 * 4) * bm.bmHeight;
}
dwLen = bi.biSize + ( GetDIBColors( (LPSTR)&bi ) * sizeof(RGBTRIPLE)) + bi.biSizeImage;
h = GlobalReAlloc( hDIB, (SIZE_T) dwLen, 0);
if ( h )
{
hDIB = h;
}
else
{
GlobalFree(hDIB);
hDIB = NULL;
SelectPalette(hDC, hPal, TRUE);
RealizePalette(hDC);
ReleaseDC(NULL, hDC);
return hDIB;
}
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
if (GetDIBits(hDC, hBitmap, 0, (UINT)bi.biHeight, (LPSTR)lpbi + (WORD)lpbi->biSize + ( GetDIBColors ((LPSTR)lpbi) * sizeof(RGBTRIPLE)) , (LPBITMAPINFO)lpbi, DIB_RGB_COLORS) == 0)
{
GlobalFree(hDIB);
hDIB = NULL;
SelectPalette(hDC, hPal, TRUE);
RealizePalette(hDC);
ReleaseDC(NULL, hDC);
return hDIB;
}
bi = *lpbi;
GlobalUnlock(hDIB);
SelectPalette(hDC, hPal, TRUE);
RealizePalette(hDC);
ReleaseDC(NULL, hDC);
return hDIB;
}
WORD GetDIBColors(LPSTR lpDIB)
{
WORD wBitCount = ((LPBITMAPCOREHEADER)lpDIB)->bcBitCount; ;
return wBitCount;
}
HB_FUNC( GETTASKBARPOSITION )
{
APPBARDATA pBarData ;
pBarData.cbSize = sizeof(pBarData);
SHAppBarMessage( ABM_GETTASKBARPOS, &pBarData );
hb_reta( 4 );
hb_storvnl( pBarData.rc.top, -1, 1 );
hb_storvnl( pBarData.rc.left, -1, 2 );
hb_storvnl( pBarData.rc.bottom, -1, 3 );
hb_storvnl( pBarData.rc.right, -1, 4 );
}
#pragma ENDDUMP
Harbour 3.1.0dev (Rev. 17036)
Copyright (c) 1999-2011,
http://harbour-project.org/
C:\Fontes\HMG\PrintScreen\demo3.prg: In function 'HB_FUN_SAVEWINDOWBYHANDLE':
C:\Fontes\HMG\PrintScreen\demo3.prg:276:34: warning: initialization discards qualifiers from pointer target type
C:\Fontes\HMG\PrintScreen\demo3.prg:306:9: warning: 'hPal' is used uninitialized in this function
C:/hmg.3.0.39/lib/libhmg.a(h_windows.o):h_windows.c:(.text+0x140): multiple definition of `HB_FUN_PRINTWINDOW'
C:/DOCUME~1/PABLOC~1/CONFIG~1/Temp/hbmk_1si9hp.dir/demo3.o:demo3.c:(.text+0xb0): first defined here
C:/hmg.3.0.39/lib/libhmg.a(h_windows.o):h_windows.c:(.text+0x160): multiple definition of `HB_FUN_SAVEWINDOW'
C:/DOCUME~1/PABLOC~1/CONFIG~1/Temp/hbmk_1si9hp.dir/demo3.o:demo3.c:(.text+0xf0): first defined here
C:/hmg.3.0.39/lib/libhmg.a(c_windows.o):c_windows.c:(.text+0x31a0): multiple definition of `ChangeBmpFormat'
C:/DOCUME~1/PABLOC~1/CONFIG~1/Temp/hbmk_1si9hp.dir/demo3.o:demo3.c:(.text+0x170): first defined here
C:/hmg.3.0.39/lib/libhmg.a(c_windows.o):c_windows.c:(.text+0x3540): multiple definition of `HB_FUN_SAVEWINDOWBYHANDLE'
C:/DOCUME~1/PABLOC~1/CONFIG~1/Temp/hbmk_1si9hp.dir/demo3.o:demo3.c:(.text+0x530): first defined here
C:/hmg.3.0.39/lib/libhmg.a(c_windows.o):c_windows.c:(.text+0x3810): multiple definition of `GetDIBColors'
C:/DOCUME~1/PABLOC~1/CONFIG~1/Temp/hbmk_1si9hp.dir/demo3.o:demo3.c:(.text+0x840): first defined here
C:/DOCUME~1/PABLOC~1/CONFIG~1/Temp/hbmk_1si9hp.dir/demo3.o:demo3.c:(.data+0x1c8): undefined reference to `HB_FUN_MSGMINIGUIERROR'
collect2: ld returned 1 exit status
hbmk2: Erro: Executando linkeditor. 1
gcc.exe C:/DOCUME~1/PABLOC~1/CONFIG~1/Temp/hbmk_1si9hp.dir/demo3.o C:/DOCUME~1/PABLOC~1/CONFIG~1/Temp/hbmk_1si9hp.dir/hbmk_nmf5hf.o C:/Fontes/HMG/PrintScreen/_temp.o -mwindows -Wl,--start-group -lhmg -lcrypt -ledit -leditex -lgraph -lhfcl -lini -lreport -lmsvfw32 -lvfw32 -lhbct -lhbwin -lhbmzip -lminizip -lhbmemio -lhbmisc -lhbmysql -lmysql -lhbtip -lsqlite3 -lhbsqlit3 -lsddodbc -lrddsql -lsddmy -lhbodbc -lodbc32 -lhbhpdf -lhbfimage -lhbpgsql -lhbnetio -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainwin -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib -Wl,--end-group -odemo3.exe -LC:/hmg.3.0.39/harbour/lib/win/mingw -LC:/hmg.3.0.39/harbour/bin -LC:/hmg.3.0.39/lib
I have posted other codes wich I also trying to compile. Sorry my mistake.