Página 1 de 2

Dialog em resource com mingw

Enviado: 07 Mar 2021 11:33
por JoséQuintas
Alguém por aí já fez o teste?

Ou... deixou de usar o mingw por não conseguir isso?

Dialog em resource com mingw

Enviado: 07 Mar 2021 12:23
por asimoes
Não entendi,

Mas para informar só uso LLVM/CLANG Harbour, HwGui e HMGE

Dialog em resource com mingw

Enviado: 07 Mar 2021 16:26
por JoséQuintas
Existe a opção de "salvar a tela" inteira em resource.
E existem editores de "tela" pra fazer isso.

Normalmente dá erro ao compilar com mingw, e sempre falaram pra nós que não dava pra fazer isso com mingw.

Dialog em resource com mingw

Enviado: 07 Mar 2021 16:55
por asimoes
JoséQuintas escreveu:Existe a opção de "salvar a tela" inteira em resource.
E existem editores de "tela" pra fazer isso.
Faço isso usando a Bostaurus em qq janela, GT, HwGui ou Minigui Ex, se é que eu entendi, mas to boiando

Dialog em resource com mingw

Enviado: 07 Mar 2021 17:13
por JoséQuintas

Código: Selecionar todos

IDD_ABOUTDIALOG DIALOGEX 0, 0, 147, 67
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
  ICON             IDI_APPICON,IDC_STATIC,7,7,20,20
  LTEXT            "Win32 Test application.",IDC_STATIC,34,7,86,8
  LTEXT            "©2013 Transmission Zero",IDC_STATIC,34,17,84,8
  DEFPUSHBUTTON    "OK",IDOK,90,46,50,14,WS_GROUP
END

Dialog em resource com mingw

Enviado: 07 Mar 2021 17:29
por asimoes
Como faz isso no resource, posso tentar por aqui e como chama essa tela?

Dialog em resource com mingw

Enviado: 07 Mar 2021 17:45
por asimoes
Coloquei no meu arquivo demo.rc

Código: Selecionar todos

#include <windows.h>

ErrorDialog DIALOG  10, 10, 300, 110
STYLE WS_POPUP | WS_BORDER
CAPTION "Error!" 
{
    CTEXT "Select One:", 1, 10, 10, 280, 12
    PUSHBUTTON "&Retry", 2, 75, 30, 60, 12
    PUSHBUTTON "&Abort", 3, 75, 50, 60, 12
    PUSHBUTTON "&Ignore", 4, 75, 80, 60, 12
}
Compilou, como faz a chamada?

Dialog em resource com mingw

Enviado: 07 Mar 2021 17:46
por asimoes
Coloquei no meu arquivo demo.rc

Coloque #include <windows.h> no início

Código: Selecionar todos

#include <windows.h>

ErrorDialog DIALOG  10, 10, 300, 110
STYLE WS_POPUP | WS_BORDER
CAPTION "Error!" 
{
    CTEXT "Select One:", 1, 10, 10, 280, 12
    PUSHBUTTON "&Retry", 2, 75, 30, 60, 12
    PUSHBUTTON "&Abort", 3, 75, 50, 60, 12
    PUSHBUTTON "&Ignore", 4, 75, 80, 60, 12
}
Compilou, como faz a chamada?

Dialog em resource com mingw

Enviado: 07 Mar 2021 18:05
por asimoes
No rc

Código: Selecionar todos

#include <windows.h>

ErrorDialog DIALOG  10, 10, 300, 110
STYLE WS_POPUP | WS_BORDER
CAPTION "Error!" 
{
    CTEXT "Select One:", 1, 10, 10, 280, 12
    PUSHBUTTON "&Retry", 2, 75, 30, 60, 12
    PUSHBUTTON "&Abort", 3, 75, 50, 60, 12
    PUSHBUTTON "&Ignore", 4, 75, 80, 60, 12
}

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

101 DIALOGEX DISCARDABLE 6, 18, 210, 174
STYLE WS_POPUP|DS_MODALFRAME|DS_CONTEXTHELP|DS_3DLOOK|DS_CENTER|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Sample Dialog (Windows API Demo With Harbour)"
FONT 8, "Segoe UI", 0, 0, 1
{
   CONTROL "", 1003, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 8, 48, 192, 14
   CONTROL "&Name:", 1002, "Static", WS_GROUP, 8, 36, 75, 10
   CONTROL "Gender", 1008, "Button", BS_GROUPBOX, 8, 104, 76, 42
   CONTROL "&Male", 1004, "Button", BS_AUTORADIOBUTTON, 20, 116, 47, 10
   CONTROL "&Female", 1005, "Button", BS_AUTORADIOBUTTON, 20, 132, 44, 10
   CONTROL "", 1006, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|CBS_SORT|CBS_HASSTRINGS|WS_VSCROLL|WS_TABSTOP, 8, 84, 192, 36
   CONTROL "&Occupation:", 1008, "Static", WS_GROUP, 8, 72, 40, 8
   CONTROL "Own a &car?", 1007, "Button", BS_AUTOCHECKBOX|WS_TABSTOP, 96, 116, 58, 10
   CONTROL "Click me!", 4001, "Button", BS_DEFPUSHBUTTON|WS_TABSTOP, 8, 156, 84, 14
   CONTROL "This example demonstrates how to work with some features of the native Windows API. The following function displays a dialog created with an external resource editor.", 4002, "Static", SS_CENTER|WS_GROUP, 4, 4, 204, 28
   CONTROL "&Has children?", 4003, "Button", BS_AUTOCHECKBOX|WS_TABSTOP, 96, 132, 58, 10
}
2021-03-07 18_03_18-Greenshot.png

Dialog em resource com mingw

Enviado: 07 Mar 2021 18:29
por asimoes
2021-03-07 18_27_57-Greenshot.png

Código: Selecionar todos

#define IDD_DIALOG2                        104

wapi_DialogBoxParam( 0, IDD_DIALOG2, 0, @DialogFunc() )

FUNCTION DialogFunc( hWnd, nMessage, wParam, lParam, wPHigh, wPLow )

   LOCAL cText

   HB_SYMBOL_UNUSED( wParam )
   HB_SYMBOL_UNUSED( lParam )
   HB_SYMBOL_UNUSED( wPHigh )

   SWITCH nMessage
   CASE WM_INITDIALOG

      wapi_SetDlgItemText( hWnd, IDC_STATIC1, "Hi! " + Time() )
      wapi_SetDlgItemText( hWnd, IDC_EDIT1, "Harbour" )

      wapi_ComboBox_AddString( wapi_GetDlgItem( hWnd, IDC_COMBO1 ), "Architect" )
      wapi_ComboBox_AddString( wapi_GetDlgItem( hWnd, IDC_COMBO1 ), "Engineer" )
      wapi_ComboBox_AddString( wapi_GetDlgItem( hWnd, IDC_COMBO1 ), "Project or Program Administrator" )
      wapi_ComboBox_AddString( wapi_GetDlgItem( hWnd, IDC_COMBO1 ), "Software Designer" )
      wapi_ComboBox_AddString( wapi_GetDlgItem( hWnd, IDC_COMBO1 ), "Other" )

      wapi_SetFocus( hWnd, wapi_GetDlgItem( hWnd, IDC_EDIT1 ) )
      RETURN .T.

   CASE WM_CLOSE
      wapi_EndDialog( hWnd, 3 )
      RETURN .T.

   CASE WM_COMMAND
      SWITCH wPLow
      CASE IDC_BUTTON1
         cText := wapi_GetDlgItemText( hWnd, IDC_EDIT1 )
         wapi_MessageBox( 0, "Hello [" + cText + "]!" + Chr( 13 ) + "How are you?", "Hi!", MB_ICONASTERISK )
         RETURN .T.
      ENDSWITCH
   ENDSWITCH 

   RETURN .F.

Código: Selecionar todos


#include "D:\GERAL\HARBOUR\APP.RC"

IDI_APPICON ICON D:\GERAL\HARBOUR\HARBOUR.ICO

#define IDC_STATIC 103
#define IDD_ABOUTDIALOG 104

IDD_ABOUTDIALOG DIALOGEX 0, 0, 147, 67
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
  ICON             IDI_APPICON,IDC_STATIC,7,7,20,20
  LTEXT            "Win32 Test application.",IDC_STATIC,34,7,86,8
  LTEXT            "©2013 Transmission Zero",IDC_STATIC,34,17,84,8
  DEFPUSHBUTTON    "OK",IDOK,90,46,50,14,WS_GROUP
END

Dialog em resource com mingw

Enviado: 07 Mar 2021 19:51
por JoséQuintas
E usou mingw?
Que estranho, aqui só com outro include.

No momento testando na hwgui, que tem arquivo assim.

Dialog em resource com mingw

Enviado: 07 Mar 2021 21:17
por asimoes
LL
JoséQuintas escreveu:E usou mingw?
LLVM/CLANG e MINGW
2021-03-07 21_16_38-Greenshot.png

Dialog em resource com mingw

Enviado: 08 Mar 2021 11:53
por JoséQuintas
O que encontrei na net foi pra no mingw usar #include <afxres.h> ao invés de #include <windows.h>

E o mais engraçado é que ao procurar sobre afxres.h, o que mais se encontra é erro no Visual Studio da Microsoft, por esse arquivo estar estragado.

Aqui só compilou RC com dialog depois de acrescentar esse include.

Isso resolve vários exemplos em LIBs que não compilavam com mingw...

Dialog em resource com mingw

Enviado: 08 Mar 2021 12:46
por asimoes
Quintas,

Eu acrescentei esse afxres.h

Deu que esse define IDC_STATIC estava duplicado no afxres.h

//#define IDC_STATIC 103

Removi e compilou,

Removi também o #include <windows.h>, continuou compilando e funcionando

Dialog em resource com mingw

Enviado: 08 Mar 2021 19:00
por JoséQuintas
Só pra curiosidade:

Código: Selecionar todos

/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the mingw-w64 runtime package.
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 */
#ifndef _AFXRES_H
#define _AFXRES_H
#if __GNUC__ >= 3
#pragma GCC system_header
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _INC_WINDOWS
#include <windows.h>
#endif

/* IDC_STATIC is documented in winuser.h, but not defined. */
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif

#ifdef __cplusplus
}
#endif
#endif
Não sei qual seria a diferença em definir como -1 ao invés de 103