1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
// DynamicDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ACTAR.h"
#include "DynamicDlg.h"
#include "ACTARDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDynamicDlg dialog
IMPLEMENT_DYNCREATE(CDynamicDlg,CDialog)
BOOL CDynamicDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//Ajouter le bouton "réduire", pas de bouton "agrandir"
SetWindowLong(this->m_hWnd, GWL_STYLE, GetWindowLong(this->m_hWnd, GWL_STYLE) | WS_MINIMIZEBOX );
//Afficher du texte dans l'espace client de la fenetre.
// le texte ne s'affiche pas!!!
CDC * Dc = GetDC( );
BOOL b = NULL;
if ( (b = TextOut(Dc->m_hDC,50,20,"hello",5)) == 0) AfxMessageBox("Echec de TextOut!!!");
//Création d'un bouton
//le bouton n'est pas ajouté!!!
CButton BoutonReessayer;
if ( BoutonReessayer.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(90,50,100,30), this, 1) == 0)
AfxMessageBox("Echec de la creation du bouton!!!");
return TRUE; // return TRUE unless you set the focus to a control
}
CDynamicDlg::CDynamicDlg()
{
m_hgbl=NULL;
}
CDynamicDlg::CDynamicDlg(int x,int y,int cx,int cy,const char *szTitle,CWnd* pParent /*=NULL*/)
: CDialog()
{
//{{AFX_DATA_INIT(CDynamicDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_hgbl=NULL;
SetDynamicDlg(x,y,cx,cy,szTitle,pParent);
}
void CDynamicDlg::SetDynamicDlg(int x,int y,int cx,int cy,const char *szTitle,CWnd* pParent /*=NULL*/)
{
//
LPDLGTEMPLATE lpdt;
LPWORD lpw;
if(m_hgbl) GlobalFree(m_hgbl);
m_hDialogTemplate=NULL;
m_hgbl=GlobalAlloc(GMEM_ZEROINIT,1024);
lpdt = (LPDLGTEMPLATE)GlobalLock(m_hgbl);
lpdt->style = WS_POPUP | WS_BORDER | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION;
lpdt->cdit = 0;
lpdt->x = x;
lpdt->y = y;
lpdt->cx = cx;
lpdt->cy = cy;
lpw=(LPWORD) (lpdt+1);
*lpw++=0;
*lpw++=0;
while(*szTitle) *lpw++=*szTitle++;
*lpw++=0;
GlobalUnlock(m_hgbl);
InitModalIndirect(m_hgbl);
}
/*
void CDynamicDlg::AjouterBouton(CACTARDlg dlg){
CButton BoutonReessayer;
if (0 == BoutonReessayer.Create("My button", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(0,0,100,30), &dlg, 1)) AfxMessageBox("ERROR");
}
*/
CDynamicDlg::~CDynamicDlg()
{
if(m_hgbl) GlobalFree(m_hgbl);
}
BEGIN_MESSAGE_MAP(CDynamicDlg, CDialog)
//{{AFX_MSG_MAP(CDynamicDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDynamicDlg message handlers |
Partager