|
Assuming wndMain is of type CMainFrame....
Add a WINDOWPLACEMENT member to the CMainFrame class, add a WINDOWPLACEMENT parameter to the CMainFrame constructor that you us to initialise the WINDOWPLACEMENT member of CMainFrame. Use that member to set the window's placement (with SetWindowPlacement) in the WM_CREATE handler?
Like this:
WINDOWPLACEMENT wp;
CMainFrame wndMain(wp);
CMainFrame(WINDOWPLACEMENT const& wp) : wp_(wp) {}
CMainFrame()
{
WINDOWPLACEMENT wp = {0};
wp.length = sizeof WINDOWPLACEMENT;
wp.showCmd = SW_SHOWNORMAL;
wp.rcNormalPosition.top = 100;
wp.rcNormalPosition.left = 100;
wp.rcNormalPosition.right = 200;
wp.rcNormalPosition.bottom = 200;
wp_ = wp;
}
WINDOWPLACEMENT wp_;
LRESULT OnCreate(UINT , WPARAM , LPARAM , BOOL& )
{
SetWindowPlacement(&wp_);
}
Yes, it works and you get the maximized client rect back in OnCreate.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
I never thought about passing the WINDOWPLACEMENT in to the CMainFrame prior to calling CreateEx(...). In the handler for WM_CREATE GetClientRect(...) now returns the expected size so I can set splitters etc up fine. Thanks.
Odd behaviour though in the case where the application was either closed from a minimized or maximized state. On restarting, the retrieved prior state is indicated by the WINDOWPLACEMENT.showCmd . When previously minimized or maximized is the case, in between the OnCreate(...) handler exiting and the following call to ShowWindow(...) something changes the WINDOWPLACEMENT.rcNormalPosition information to either the size and position of a minimized or a maximized window respectively. This then means when the User Restores, it 'restores' to exactly the same minimized or maximized size! To the eye the window stays as it was.
I had to work around this by resetting the WINDOWPLACEMENT again after CreateEx returns. I found I also had to call ShowWindow with the retreived showCmd rather than nCmdShow and remove any saved WPF_RESTORETOMAXIMIZED flag.
int Run(LPTSTR = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
...
if(WindowPlacement.flags & WPF_RESTORETOMAXIMIZED)
{
WindowPlacement.flags &= WPF_SETMINPOSITION;
}
CMainFrame wndMain(WindowPlacement);
wndMain.CreateEx();
wndMain.SetWindowPlacement(&WindowPlacement);
wndMain.ShowWindow(WindowPlacement.showCmd);
...
Why this is necessary I don't know. Anyway it all seems OK now so thanks.
|
|
|
|
|
what is the purpose of the following properties in the Object tag:
PARAM NAME="_Version" VALUE="458752"
PARAM NAME="_ExtentX" VALUE="9843"
PARAM NAME="_ExtentY" VALUE="7373"
PARAM NAME="_StockProps" VALUE="1"
Some details would be appreciated as to what each property is I have seen these properties on a number of controls in web pages.
Thanks in advance.
|
|
|
|
|
Its used to set the default value for the property identified by NAME.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks for your reply, Which property are you referring too?
|
|
|
|
|
Property of the embedded object.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Sorry Superman, your not making any sense. Have you read the question? I am looking for a breakdown of what EACH property means and there purpose.
|
|
|
|
|
Oh! That is totally dependent on the object that is being embedded.
Those are custom properties I guess.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
In the wizard I'm working on I need to bring up a window that allows our users to select a folder to gather files from. I figured that CFolderDialogImpl would work just dandy. However, I wanted to remove the 'Make New Folder' button (which I was able to do by using Spy++ to find out it's ID and hide it) and replace it with a check box that the user can check to specify whether or not to recurse into subdirectories of the selected folder. I created a dialog in the resource editor with just a checkbox in it (IDC_CHECK_RECURSE is the resource ID for the checkbox, and it belongs to IDD_ENHANCED_FOLDER_DIALOG).
My problem is that I can't, for the life of me, get the check box that I created in the resource editor to show up! I know that I haven't set anything up to handle the messages for my check box. I'm more concerned with just getting the dang thing to show up first.
Here is what the class looks like...
class CFolderDialogEx : public CFolderDialogImpl<CFolderDialogEx>
{
protected:
typedef CFolderDialogImpl<CFolderDialogEx> baseClass;
typedef CFolderDialogEx thisClass;
public:
enum DialogIds
{
_IDC_STATUSTEXT = 0x00003741,
_IDC_TITLE = 0x00003742,
_IDC_NEW_FOLDER = 0x00003746,
};
enum { IDD = IDD_ENHANCED_FOLDER_DIALOG };
CFolderDialogEx(HWND hWndParent = NULL, LPCTSTR lpstrTitle = NULL, UINT uFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT)
: baseClass(hWndParent, lpstrTitle, uFlags)
{
}
BEGIN_MSG_MAP(thisClass)
END_MSG_MAP()
void OnInitialized()
{
if((m_bi.ulFlags & BIF_NEWDIALOGSTYLE) == BIF_NEWDIALOGSTYLE &&
(m_bi.ulFlags & BIF_STATUSTEXT) == BIF_STATUSTEXT)
{
int fontHeight = 11;
CWindow title = ::GetDlgItem(m_hWnd, _IDC_TITLE);
RECT rcTitle = {0};
if(title)
{
CFontHandle titleFont = title.GetFont();
CLogFont logFont;
titleFont.GetLogFont(logFont);
if(logFont.lfHeight < 0)
fontHeight = -1*logFont.lfHeight;
title.GetWindowRect(&rcTitle);
::MapWindowPoints(NULL, title.GetParent(), (LPPOINT)&rcTitle, 2);
rcTitle.top -= 1;
rcTitle.bottom -= fontHeight + 1;
title.SetWindowPos(NULL, &rcTitle, (SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW));
}
CWindow status = ::GetDlgItem(m_hWnd, _IDC_STATUSTEXT);
if(status)
{
status.EnableWindow(TRUE);
status.ModifyStyle(0,SS_PATHELLIPSIS|SS_NOPREFIX);
rcTitle.top = rcTitle.bottom + 2;
rcTitle.bottom = rcTitle.top + fontHeight + (fontHeight/2);
status.SetWindowPos(NULL, &rcTitle, (SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW));
}
}
CRect rect;
CWindow makeNewFolderButton = ::GetDlgItem(m_hWnd, _IDC_NEW_FOLDER);
if ( makeNewFolderButton.IsWindow() )
{
makeNewFolderButton.ScreenToClient( &rect );
makeNewFolderButton.ShowWindow( SW_HIDE );
CWindow recurseBox = ::GetDlgItem( this->m_hWnd, IDC_CHECK_RECURSE );
DWORD error;
error = GetLastError();
if ( recurseBox.IsWindow() )
{
recurseBox.MoveWindow( &rect );
recurseBox.ShowWindow( SW_NORMAL );
}
}
}
....
recurseBox.m_hWnd is NULL, which makes the if ( recurseBox.IsWindow() ) fail.
error is ERROR_CONTROL_ID_NOT_FOUND
I'm completely aware that I may be going about this all wrong. All I want to do is have a folder dialog with the checkbox that let's the user specify whether or not to recurse into subdirectories. I don't really care how it gets done, as long as it gets done. Any help would be very much appreciated!
Thanks!
|
|
|
|
|
I'd be tempted to do it slightly differently for various reasons, the main one being that I don't think SHBrowseForFolder (the underlying API) allows controls to be added to its dialog.
Anyway - why not have a separate dialog with three controls - an edit box containing the text of the path, a 'browse' button that would show the folder browsing dialog (the result of which would get put back into the text box) and a check box for the recursion control.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The following code is correct:
FRLE_FALSE(m_pRssManager.CreateInstance(RssLib::CLSID_RssManager),_T("can't create RssManager object"));
CString sRssDBFile = (LPCTSTR)(GlobalSet::g_sRootPath + _T("\\DB\\RssTab.mrr"));
try{
m_pRssManager->Open((LPCTSTR)sRssDBFile);
}
catch(...)
{
MessageBox(::AfxGetMainWnd()->m_hWnd, _T("database file is already damaged,will create a new empty database file"),_T("message"),MB_OK|MB_ICONINFORMATION);
CString sRssDBTemplateFile = (LPCTSTR)(GlobalSet::g_sRootPath + _T("\\NewRssTab.mrr"));
if( ::PathFileExists(sRssDBTemplateFile) ){
::CopyFile(sRssDBTemplateFile, sRssDBFile, FALSE);
RssLib::IRssManagerPtr pRssManager;
FRLE_FALSE(pRssManager.CreateInstance(RssLib::CLSID_RssManager),_T("can't create RssManager object"));
pRssManager->Open((LPCTSTR)sRssDBFile);
m_pRssManager = pRssManager;
}
}
the following code is not correct:
FRLE_FALSE(m_pRssManager.CreateInstance(RssLib::CLSID_RssManager),_T("can't create RssManager object"));
CString sRssDBFile = (LPCTSTR)(GlobalSet::g_sRootPath + _T("\\DB\\RssTab.mrr"));
try{
m_pRssManager->Open((LPCTSTR)sRssDBFile);
}
catch(...)
{
MessageBox(::AfxGetMainWnd()->m_hWnd, _T("database file is already damaged,will create a new empty database file"),_T("message"),MB_OK|MB_ICONINFORMATION);
CString sRssDBTemplateFile = (LPCTSTR)(GlobalSet::g_sRootPath + _T("\\NewRssTab.mrr"));
if( ::PathFileExists(sRssDBTemplateFile) ){
::CopyFile(sRssDBTemplateFile, sRssDBFile, FALSE);
m_pRssManager ->Open((LPCTSTR)sRssDBFile);
}
}
May I ask the reason ? Why have to recreate the RssManager object ?
thanks a lot!
sdfdsfsd
|
|
|
|
|
Try formatting the code using the 'code block' button, so that indents aren't lost - that is pretty much unreadable, which makes it unlikely that someone's going to answer your query.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thanks. this query is resolves. it is not relate com, it is other question.
sdfdsfsd
|
|
|
|
|
Hi,
I wonder for an ATL COM DLL, is there any way I can dynamically assign the UUIDs to the COM class and interface, i.e. without recompiling the code? Assume all the registries are setup correctly. Is it possible that when the dll gets loaded, the CLSID, IID are reset to the new value?
Thanks!
Lucy
|
|
|
|
|
This actually must be in the COM forum. Anyway...
You can use UuidCreate API to generate new UUIDs.
Replace the registry entries with the new UUIDs under CLSID and IID keys under HKEY_CLASSES_ROOT .
Do this after the COM DLL has been loaded.
This should work.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
We want a Pointer list in ATL, similar to CPtrList in C++
|
|
|
|
|
Don't think there is one as such. What type are the pointers?
|
|
|
|
|
Thanks!
Class Object Pointers, we need to store it an List to track the objects created, We are now using vectors for this purpose
|
|
|
|
|
If as you say you need to store in a List it's probably best to see Stuart's answer, though vector will or course do the job.
|
|
|
|
|
Would a standard list of pointers do, i.e. std::list<MyType*> ?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
CPtrList is not in c++, it is in vc++
sdfdsfsd
|
|
|
|
|
Hi,Am NATARAJAN from mumbai.I wanted to clarify a doubt that,whether in Adobe Acrobat Reader version 6.0,Add-ins can be developed?If so what's the logic & development procedures involved in it?
Iam using Windows-XP as OS & VC++6.0(ATL/COM) as tool.
Thanks in advance,
V.NATARAJAN
|
|
|
|
|
I am creating an ATL/WTL application in which i need to create a window.I have created the window now i need to create button, label and list view on it dynamically and attach these controls to the main window.
Also i have classes for button and labels....like CMyButton....etc
Please help..?
Thanks in advance.
|
|
|
|
|
Create using the parent and position as parameters, making sure they are set to visible. Messages from controls are WM_COMMAND with the controls ID as a parameter.
|
|
|
|
|
Thanks for the reply .
But can you please provide a sample code snippet to make it more clear.........?
|
|
|
|