Menu

#48 Hwgui load image

v1.0_(example)
closed
nobody
None
1
2025-03-07
2020-07-19
No

Hi!
Linux OS.

#include "hwgui.ch"
Function Main
Local oFormMain, oFontMain
Local cDirBase := hb_DirBase()
Local cImageMain := cDirBase+"imagens/main.bmp" 
Local oBmp := HBitmap():AddFile(cImageMain) //,,.F.,hwg_Getdesktopwidth(),hwg_Getdesktopheight()-21)
Local nPosX := hwg_Getdesktopwidth() 
Local nPosY := hwg_Getdesktopheight()
Local oIconEXE := HIcon():AddFile("imagens/agenda.ico") //HIcon():AddResource("ICON_1") 

PREPARE FONT oFontMain NAME "MS Sans Serif" WIDTH 0 HEIGHT -14 ;

INIT WINDOW oFormMain MAIN APPNAME "Hwgui SAMPLE" FONT oFontMain BACKGROUND BITMAP HBitmap():AddFile(cImageMain) ;
TITLE "Main SAMPLE" AT 0,0 SIZE nPosX,nPosY-30 ICON oIconEXE STYLE WS_POPUP +  WS_CAPTION + WS_SYSMENU
hwg_msginfo(cImageMain)
oFormMain:Activate()
Return Nil 

In main window not load ICON, not load BMP.
Icon load ONLY hwg_msginfo(cImageMain) // not show window main.
Other problem, how to compile a file resource.rc ?

Best regards,
Itamar M. Lins Jr.

Discussion

  • Wilfried Brunken

    Hello Itamar,
    i give you an intermediate solution (r2864):
    Created a new sample based on your post
    (WinAPI and GTK).
    Fixed the Problem for the main window
    but app crashes calling a dialog from the menu
    INIT DIALOG ...

    Error BASE/1004 No exported method: HANDLE
    Called from HANDLE(0)
    Called from HWG_CREATEDLG(0)
    Called from HDIALOG:NEW(114)

    I'll fix this bug as soon as possible.
    (Sorry, i am very busy )

    The background image is tiled as well,
    the sample works best with WinAPI.

    I hope, this helps you at the first time.

    If anyone have an idea why the same
    instructions of INIT WINDOW in INIT DIALOG
    crashes, please post a hint.

    The resource compiler is a Windows only feature.
    With GTK, it is only possible to work with
    .ico or .bmp files.

    Please give feedback, if you have success.
    With regards,
    MNI TNX, 73 es 55 de
    DF/BE, Wilfried

     
  • Itamar M. Lins Jr.

    Hi!
    No problem with menu, but with this line ?
    Of /source/gtk/window.c

    gdk_pixbuf_render_pixmap_and_mask(szBackFile->handle, &background, NULL, 0);
    
    icons:33907): Gdk-CRITICAL **: 17:25:12.086: IA__gdk_pixbuf_render_pixmap_and_mask_for_colormap: assertion 'GDK_IS_PIXBUF (pixbuf)' failed
    (icons:33907): Gtk-CRITICAL **: 17:25:12.086: IA__gtk_window_set_icon: assertion 'icon == NULL || GDK_IS_PIXBUF (icon)' failed
    

    And stretch of image not works.

    Best regards,
    Itamar M. Lins Jr.

     

    Last edit: Itamar M. Lins Jr. 2020-08-02
  • Wilfried Brunken

    Hello Itamar,
    i found only one working sample for background images in the internet and i
    added the instructions simular to the HWGUI library.
    I have no problems on my Ubuntu 16 system, the
    main window could be stretched and the assertion failure message does not appear.
    I modified icons.prg, so that the main windows appears with not the full size (r2865).
    Same sample works also best on WinAPI.

    Here my version info's of my test system (a little bit older computer, AMD 64 processor):

    uname -a
    Linux afulinux4 4.4.0-184-generic #214-Ubuntu SMP Thu Jun 4 10:14:11 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

    gcc --version
    gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609

    dpkg -l | grep libgtk2.0.0
    ii libgtk2.0-0:amd64 2.24.30-1ubuntu1.16.04.2 amd64 GTK+ graphical user interface library

    Harbour: code snapshot from core-master_2020-02-10.zip

    This week i fixed a problem with the cancel in file selection dialogs
    (sorry i am very busy), but i will check your case on my other
    oldtimer computers (MintLINUX and Ubuntu 18) within the next few days.
    I'll post my result as soon as possible.
    It is more important to fix the crash calling the DIALOG with background,
    i needed some time for it. If you have an idea, please respond.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

    Appendix:
    Additional info for this Ticket:
    Class hierarchy and defined attributes:

    CLASS HCustomWindow INHERIT HObject
    ...
    DATA handle INIT 0

    !
    ! (inherits)
    v
    CLASS HWindow INHERIT HCustomWindow
    ...
    DATA oIcon, oBmp
    ...
    METHOD New( oIcon, ...oBmp, ...)
    ::oIcon := oIcon
    ::oBmp := oBmp

    !
    ! (inherits)
    v
    CLASS HDialog INHERIT HWindow
    METHOD New(..., oBmp, oIcon, ...)
    ...
    ::oBmp := oBmp
    ::oIcon := oIcon
    ...

    crashes here:
    ::handle := Hwg_CreateDlg( Self )

    ==> Error stack see earlier post .

    icons.prg:
    INIT DIALOG oModDlg TITLE "Dialog with background image" ;
    AT 210,10 SIZE 300,300 ;
    BACKGROUND BITMAP HBitmap():AddFile(cimgpfad + "astro.bmp" )
    // ICON HIcon():AddFile(cimgpfad + "cancel.ico")

    No crash, if BACKGROUND BITMAP removed, but no background displayed (of course)
    ICON has no problem.

     
  • Itamar M. Lins Jr.

    Hi!
    This sample show image stretch via @ x,y BITMAP, but not works via hbitmap:addfile()

    #include "hwgui.ch"
    Function Main(lStretch)
    Local oFormMain 
    Local nPosX := hwg_Getdesktopwidth() 
    Local nPosY := hwg_Getdesktopheight()
    LOCAL cDirSep := hb_PS() //PATH SEPARATOR
    Local cImagePath := ".."+ cDirSep + ".." + cDirSep + "image" + cDirSep 
    Local cImageMain := cImagePath + "hwgui.bmp"
    Local oBmp := HBitmap():AddFile(cImageMain,,.F.,hwg_Getdesktopwidth(),hwg_Getdesktopheight()-21) //Here default is stretch image
    
    lStretch := iif( lStretch == Nil,lStretch:=.T.,lStretch:=.F.)
    
    If lStretch
       INIT WINDOW oFormMain MAIN AT 0,0 SIZE nPosX,nPosY
       @ 0,0 BITMAP cImageMain size nPosX-10,nPosY-100 //Here stretch
       oFormMain:Activate()
    Else
       INIT WINDOW oFormMain APPNAME "Agenda Hwgui" MAIN AT 0,0 SIZE nPosX,nPosY BACKGROUND BITMAP oBmp //Side by side, not stretch :(
    
       oFormMain:Activate()
    EndIf
    Return Nil 
    

    Best regards,
    Itamar M. Lins Jr.

     
  • Wilfried Brunken

    • status: open --> closed
     
  • Wilfried Brunken

    Ticket closed.
    Same as Support ticket:
    86 Option for sized backgroud bitmap on window main.
    The solution is presented there.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     

Log in to post a comment.

MongoDB Logo MongoDB