My question is ultra simple -
When I have a dialog box as the main window, how do I specify the DWSTYLE of the window it shows?
Project_Main_Header.h
Code:#include <afxwin.h> #include <afxcmn.h> #ifndef _DIALOGASMAINWINDOW_H_ #define _DIALOGASMAINWINDOW_H_ class CMyApp : public CWinApp { public: virtual BOOL InitInstance(); }; class CMainDialog : public CDialog { public: //Constructor for the main dialog CMainDialog(); //Function Prototype Declarations for Buttons void OnDialogExit(); void OnInsertAbove(); void OnInsertBelow(); void OnAddTask(); void OnDeleteTask(); //Function Prototype Declaration for Initialization //of ListCtrl void OnInitListCtrl(); protected: virtual void DoDataExchange(CDataExchange *pDX); virtual BOOL OnInitDialog(); virtual void PostNcDestroy(); afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() private: CListCtrl *pListCtrl; }; #endif
Project_Main_Code.cpp
Code:#include "Project_Main_Header.h" #include "resource.h" CMyApp myApp; BOOL CMyApp::InitInstance() { //Create dialog box as the main window m_pMainWnd = new CMainDialog; m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(CMainDialog,CDialog) //Message Handlers for the button pressed ON_BN_CLICKED(IDC_BUTTON_EXIT,OnDialogExit) ON_BN_CLICKED(IDC_BUTTON_ADD,OnAddTask) ON_BN_CLICKED(IDC_BUTTON_DELETE,OnDeleteTask) ON_BN_CLICKED(IDC_BUTTON_INSA,OnInsertAbove) ON_BN_CLICKED(IDC_BUTTON_INSB,OnInsertBelow) //Message Handler to repaint the dialog box ON_WM_PAINT() END_MESSAGE_MAP() CMainDialog::CMainDialog() { //Constructor to create the dialog box Create(IDD_MAIN_DIALOG); } BOOL CMainDialog::OnInitDialog() { CDialog::OnInitDialog(); //Initialization function call for ListCtrl. OnInitListCtrl(); return TRUE; } void CMainDialog::DoDataExchange(CDataExchange *pDX) { } void CMainDialog::OnInitListCtrl() { //Retrieve Dialog item for List Ctrl //And store it in pListCtrl pListCtrl = (CListCtrl*) GetDlgItem(IDC_LIST_TASK); //Insert all columns displayed on the list control pListCtrl->InsertColumn(0,"Start Time",LVCFMT_LEFT,100); pListCtrl->InsertColumn(1,"Month",LVCFMT_CENTER,100); pListCtrl->InsertColumn(2,"Date",LVCFMT_CENTER,100); pListCtrl->InsertColumn(3,"Day",LVCFMT_CENTER,100); pListCtrl->InsertColumn(4,"Year",LVCFMT_CENTER,100); pListCtrl->InsertColumn(5,"Title",LVCFMT_CENTER,270); } void CMainDialog::OnPaint() { CPaintDC dc (this); } void CMainDialog::OnDialogExit() { DestroyWindow(); } void CMainDialog::OnInsertAbove() { } void CMainDialog::OnInsertBelow() { } void CMainDialog::OnAddTask() { } void CMainDialog::OnDeleteTask() { } void CMainDialog::PostNcDestroy() { delete this; }




Reply With Quote