PDAclub.pl - Forum użytkowników technologii mobilnych
Windows Mobile (Classic, Professional, Standard), Windows Phone 6.x oraz 7/8.x/10 => Oprogramowanie PPC => Dla programistów => Wątek zaczęty przez: kielnia w Marzec 17, 2006, 00:37:01
-
Witam
Mam pytanie odnośnie dialogów a konkretnie chodzi mi o to jak zrobić aby dialog który wywołam po przez przycisk lub komendę z menu pojawił mi się na wierzchu i dodatkowo nie dopasowywał się do ekranu tylko miał taki rozmiar (mniejszy niż ekran - bo taki zaprojektowałem) - coś jak messagebox
W internecie znalazłem cos takiego ale niestety nie potrafie sobie z tym poradzić. Może ktoś napisze jak konkretnie tego użyć (kawałek kodu). Myslę że ktos już z was programistów używał/stosował coś takiego dlatego kieruję do was moje pytanie.
Oto link:
http://www.pocketpcdn.com/articles/non_fullscreen_dialog.html
Pozdrawiam i mam nadzieję że ktoś szybko odpowie.
-
jeśli klepiesz w MFC, to musisz:
1. w swoim dialogu w konstruktorze ustawić:
m_bFullScreen = FALSE;
2. przeciążyć komunikaty: WM_ACTIVATE i WM_SETTINGCHANGE, czyli
w .cpp:
BEGIN_MESSAGE_MAP( CNonFullScreenDialog, CDialog )
//{{AFX_MSG_MAP(CNonFullScreenDialog)
//}}AFX_MSG_MAP
ON_WM_ACTIVATE()
ON_WM_SETTINGCHANGE()
END_MESSAGE_MAP()
void CNonFullScreenDialog::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized )
{
CWnd::OnActivate(nState, pWndOther, bMinimized);
}
void CNonFullScreenDialog::OnSettingChange( UINT uFlags, LPCTSTR lpszSection )
{
CWnd::OnSettingChange( uFlags, lpszSection );
}
w .h:
afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized );
afx_msg void OnSettingChange( UINT uFlags, LPCTSTR lpszSection );
DECLARE_MESSAGE_MAP()
-
Witam
Posłuchałem sie Twoich rad i niestety wywaliło mi aż 30 błędów kompilacji
--------------------Configuration: Okienko - Win32 (WCE emulator) Debug--------------------
Compiling...
Okienko.cpp
D:\projekty\Okienko\WiadomoscDlg.h(24) : error C2501: 'm_bFullScreen' : missing storage-class or type specifiers
OkienkoDlg.cpp
D:\projekty\Okienko\WiadomoscDlg.h(24) : error C2501: 'm_bFullScreen' : missing storage-class or type specifiers
WiadomoscDlg.cpp
D:\projekty\Okienko\WiadomoscDlg.h(24) : error C2501: 'm_bFullScreen' : missing storage-class or type specifiers
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2653: 'CNonFullScreenDialog' : is not a class or namespace name
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2248: 'messageMap' : cannot access protected member declared in class 'CDialog'
D:\Program Files\Windows CE Tools\wce420\POCKET PC 2003\mfc\include\afxwin.h(2669) : see declaration of 'messageMap'
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2653: 'CNonFullScreenDialog' : is not a class or namespace name
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2270: 'GetMessageMap' : modifiers not allowed on nonmember functions
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2653: 'CNonFullScreenDialog' : is not a class or namespace name
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2065: 'messageMap' : undeclared identifier
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2653: 'CNonFullScreenDialog' : is not a class or namespace name
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2373: 'messageMap' : redefinition; different type modifiers
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2653: 'CNonFullScreenDialog' : is not a class or namespace name
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2653: 'CNonFullScreenDialog' : is not a class or namespace name
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2065: '_messageEntries' : undeclared identifier
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2109: subscript requires array or pointer type
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2102: '&' requires l-value
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2653: 'CNonFullScreenDialog' : is not a class or namespace name
D:\projekty\Okienko\WiadomoscDlg.cpp(38) : error C2040: '_messageEntries' : 'const struct AFX_MSGMAP_ENTRY []' differs in levels of indirection from 'int'
D:\projekty\Okienko\WiadomoscDlg.cpp(41) : error C2065: 'OnActivate' : undeclared identifier
D:\projekty\Okienko\WiadomoscDlg.cpp(41) : error C2440: 'type cast' : cannot convert from 'int *' to 'void (__thiscall CWnd::*)(unsigned int,class CWnd *,int)'
There is no context in which this conversion is possible
D:\projekty\Okienko\WiadomoscDlg.cpp(42) : error C2065: 'OnSettingChange' : undeclared identifier
D:\projekty\Okienko\WiadomoscDlg.cpp(42) : error C2440: 'type cast' : cannot convert from 'int *' to 'void (__thiscall CWnd::*)(unsigned int,const unsigned short *)'
There is no context in which this conversion is possible
D:\projekty\Okienko\WiadomoscDlg.cpp(45) : error C2653: 'CNonFullScreenDialog' : is not a class or namespace name
D:\projekty\Okienko\WiadomoscDlg.cpp(46) : error C2373: 'OnActivate' : redefinition; different type modifiers
D:\projekty\Okienko\WiadomoscDlg.cpp(47) : error C2248: 'OnActivate' : cannot access protected member declared in class 'CWnd'
D:\Program Files\Windows CE Tools\wce420\POCKET PC 2003\mfc\include\afxwin.h(2251) : see declaration of 'OnActivate'
D:\projekty\Okienko\WiadomoscDlg.cpp(47) : error C2352: 'CWnd::OnActivate' : illegal call of non-static member function
D:\Program Files\Windows CE Tools\wce420\POCKET PC 2003\mfc\include\afxwin.h(2251) : see declaration of 'OnActivate'
D:\projekty\Okienko\WiadomoscDlg.cpp(49) : error C2653: 'CNonFullScreenDialog' : is not a class or namespace name
D:\projekty\Okienko\WiadomoscDlg.cpp(50) : error C2373: 'OnSettingChange' : redefinition; different type modifiers
D:\projekty\Okienko\WiadomoscDlg.cpp(51) : error C2248: 'OnSettingChange' : cannot access protected member declared in class 'CWnd'
D:\Program Files\Windows CE Tools\wce420\POCKET PC 2003\mfc\include\afxwin.h(2323) : see declaration of 'OnSettingChange'
D:\projekty\Okienko\WiadomoscDlg.cpp(51) : error C2352: 'CWnd::OnSettingChange' : illegal call of non-static member function
D:\Program Files\Windows CE Tools\wce420\POCKET PC 2003\mfc\include\afxwin.h(2323) : see declaration of 'OnSettingChange'
Generating Code...
Error executing cl.exe.
Okienko.exe - 30 error(s), 0 warning(s)
Oto kod pliku cpp dialogu który ma być ma być "non-full screen" po zmianie
// WiadomoscDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Okienko.h"
#include "NonFSDialog.h"
#include "WiadomoscDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWiadomoscDlg dialog
CWiadomoscDlg::CWiadomoscDlg(CWnd* pParent /*=NULL*/)
: /*CNonFSDialog*/CDialog(CWiadomoscDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CWiadomoscDlg)
m_poleedit = _T("");
m_wybor = FALSE;
//}}AFX_DATA_INIT
}
void CWiadomoscDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWiadomoscDlg)
DDX_Text(pDX, IDC_TEXTPOLE, m_poleedit);
DDX_Check(pDX, IDC_WYBOR, m_wybor);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP( CNonFullScreenDialog, CDialog )
//{{AFX_MSG_MAP(CNonFullScreenDialog)
//}}AFX_MSG_MAP
ON_WM_ACTIVATE()
ON_WM_SETTINGCHANGE()
END_MESSAGE_MAP()
void CNonFullScreenDialog::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized )
{
CWnd::OnActivate(nState, pWndOther, bMinimized);
}
void CNonFullScreenDialog::OnSettingChange( UINT uFlags, LPCTSTR lpszSection )
{
CWnd::OnSettingChange( uFlags, lpszSection );
}
/////////////////////////////////////////////////////////////////////////////
// CWiadomoscDlg message handlers
A to kod pliku h po zmianie w
#if !defined(AFX_WIADOMOSCDLG_H__9146CE8F_45E6_4E8E_9BA0_EE0ADA91E049__INCLUDED_)
#define AFX_WIADOMOSCDLG_H__9146CE8F_45E6_4E8E_9BA0_EE0ADA91E049__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// WiadomoscDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CWiadomoscDlg dialog
class CWiadomoscDlg : public /*CNonFSDialog*/CDialog
{
// Construction
public:
CWiadomoscDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CWiadomoscDlg)
enum { IDD = IDD_DIALOG1 };
CString m_poleedit;
BOOL m_wybor;
m_bFullScreen = FALSE;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWiadomoscDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CWiadomoscDlg)
//}}AFX_MSG
afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized );
afx_msg void OnSettingChange( UINT uFlags, LPCTSTR lpszSection );
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_WIADOMOSCDLG_H__9146CE8F_45E6_4E8E_9BA0_EE0ADA91E049__INCLUDED_)
Może robie coś nie tak - a zapewne tak jest wiec prosze o wytłumaczenie.
Dodatkowo w internecie znalazłem takie coś i kierowałem sie tym ( dodałem do projektu oba pliki cpp i h oraz pozmieniałem CDialog na CNonFSDialog tam gdzie nalezy ale także wyskakiwał mi błąd kompilacji na szczęście tylko 1 - coś o tym że CNonFSDialog nie ma bazowej klasy - trochę to dziwne skoro dodało się dwa pliki (cpp i h) gdzie klasa była zdefiniowana.
Podaję link:
http://www.codeproject.com/ce/nonfullscreendialog.asp
Pozdrawiam.
-
1. zmień CNonFullScreenDlg na CWiadomoscDlg
2. konstruktor to :
CWiadomoscDlg::CWiadomoscDlg(CWnd* pParent /*=NULL*/)
: /*CNonFSDialog*/CDialog(CWiadomoscDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CWiadomoscDlg)
m_poleedit = _T("");
m_wybor = FALSE;
//}}AFX_DATA_INIT
}
a nie fragment deklaracji zmiennych w .h, i to w konstruktorze miałeś umieścić wpisanie FALSE do zmiennej m_bFullScreen
-
Dzięki Fp - działa i to jak nalezy :D :D :D
Jakie błedy człowiek robi jak się nie bardzo orientuje w c++, ech uczyć sie i czytać trzeba......
Ważne jest to że z waszą pomocą jakoś sprawniej można sobie poradzić.
Byłoby miło FP jakbyś jeszcze zajżał do mojego postu dotyczącego menu kontekstowego i wyjaśnił sprawę - byłoby fest.
Pozdrawiam.