|
This is the situation of my problem:
*** My application is a GUI dll (SDI) it seems to work like windows explorer i.e if i select a folder in tree on the right its content will be displayed on the left.
- I have a CView derived class named CMyView which contains a CListCtrl derived class named CBCGPShellList like this :
class CMyView : public CView
{
public:
...
CBCGPShellList m_wndList;
...
- I have also a CBCGPControlBar derived class which contains a CBCGPShellTree
class CFolderBar : public CBCGPDockingControlBar
{
public:
...
CBCGPShellTree m_wndShellTree;
...
- I have also MainFrame contains this two classes.
So what i need is to do like this :
when i create a new file in a specific folder (selected in the right) the application should give the user the possibility to enter a name to this file.
I hope that i had describe my situation clearly and you can help me.
thank you.
|
|
|
|
|
I am not familiar with the CBCGPShellList control, it does not appear to be part of MFC, so cannot advise on its use. Using a normal ListView the application may be able to set the editing mode on the name element which will give the user what you want.
|
|
|
|
|
1) the CBCGPShellList derive from CListCtrl so if you find a solution to CListCtrl it will be similar to CBCGPShellList.
2) About the uses of this class "CBCGPShellList" and "CBCGPShellTree" is for some reasons like the automatic manage of events between this controls and to use the BCG customization .
If you have source code in c++ which has the same role of my application (windows explorer) it will be helpful for me and a great gift.
thanks
|
|
|
|
|
Sorry but I have no idea about these controls, or BCG customization. I do know that using a ListView you can do what you are asking; take a look at the ListView/CListView documentation on MSDN.
|
|
|
|
|
No problem, thank you for your help
|
|
|
|
|
You should have code that gets called to create the temporary edit control in the listview. Just call that code right after the folder is created rather than in response to a button click, menu option, or F2.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
but here we need to specify the new name in the call !!!
I need to let the user rename the file created just after the creation
|
|
|
|
|
Anyone know how to change the background color of a button using CColorDialog?
Will this work?
void CCustomButtonDlg::OnButtonFace()
{
CColorDialog dlg;
dlg.m_cc.Flags |= CC_FULLOPEN | CC_RGBINIT ;
dlg.m_cc.rgbResult = RGB( 255, 0, 0 );
dlg.DoModal();
HBRUSH hbr;
if (GetDlgCtrlID() == IDC_CUSTOM_BUTTON)
{
CDC *cDC;
cDC = m_CustomButton.GetDC();
cDC->SetBkColor(dlg.GetColor());
hbr = m_brush;
}
UpdateData();
}
modified on Monday, October 5, 2009 5:39 AM
|
|
|
|
|
Use the OnCtlColor message handler, see [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Will this work?
void CCustomButtonDlg::OnButtonFace()
{
CColorDialog dlg;
dlg.m_cc.Flags |= CC_FULLOPEN | CC_RGBINIT ;
dlg.m_cc.rgbResult = RGB( 255, 0, 0 );
dlg.DoModal();
HBRUSH hbr;
if (GetDlgCtrlID() == IDC_CUSTOM_BUTTON)
{
CDC *cDC;
cDC = m_CustomButton.GetDC();
cDC->SetBkColor(dlg.GetColor());
hbr = m_brush;
}
UpdateData();
}
|
|
|
|
|
I don't know (what -the fresh hell - is CCustomButtonDlg ?): try it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ratprita wrote: Will this work?
No, but responding to the WM_CTLCOLORBTN message will.
ratprita wrote: UpdateData();
Seriously?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi there,
I got the strangest problem. I want to start an executable with ShellExecute(). Which usually works fine, but ...
(this is the code)
[edit]
char buf[512]
size = GetCurrentDirectoryA( 512, buf );
[/edit]
char callString[1024];
sprintf_s( callString, "%s\\%s", buf, file.c_str() );
char buf[1024];
sprintf_s( buf, "c:\\Users\\zwatschek\\work\\svn\\incubation\\ttsServer\\Data\\ttsWatchdog.exe" );
char id[32];
sprintf_s( id, "%d", pid );
long res=long(ShellExecute(0, "open", callString, id, 0, SW_SHOWNORMAL));
... with version 2 things work fine, with version 1 I get ERROR_FILE_NOT_FOUND.
callString = c:\Users\zwatschek\work\svn\incubation\ttsServer\Data\ttsWatchdog.exe
buf = c:\Users\zwatschek\work\svn\incubation\ttsServer\Data\ttsWatchdog.exe
(I copied those strings right out from the variable watch)
Does anyone have an idea on this?
Souldrift
modified on Monday, October 5, 2009 5:00 AM
|
|
|
|
|
There's something wrong in the posted snippet:
Souldrift wrote: // version 1
char callString[1024];
sprintf_s( callString, "%s\\%s", buf, file.c_str() );
Here you're using a uninitialised buf variable (as far as I can tell from the posted code...).
Souldrift wrote: har buf[1024];
sprintf_s( buf, "c:\\Users\\zwatschek\\work\\svn\\incubation\\ttsServer\\Data\\ttsWatchdog.exe" );
char id[32];
sprintf_s( id, "%d", pid );
long res=long(ShellExecute(0, "open", callString, id, 0, SW_SHOWNORMAL));
here you're copying (with a wrong call to sprintf_s - missing len parameter-) the file name to the buf variable, but, afterwards, you're not using buf in ShellExecute .
Please check through the posted code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I edited the code block. buf was initialized, of course, further above.
In ShellExecute() I tried 'callString' and 'buf' as parameter. But only 'buf' worked.
'buf' is in the example NOT in the ShellExecute(), since I tried last with 'callString'. hm ... I post the code differently ...
char buf[512]
size = GetCurrentDirectoryA( 512, buf );
char id[32];
sprintf_s( id, "%d", pid );
char callString[1024];
sprintf_s( callString, "%s\\%s", buf, file.c_str() );
long res=long(ShellExecute(0, "open", callString, id, 0, SW_SHOWNORMAL));
char callString2[1024];
sprintf_s( callString2, "c:\\Users\\zwatschek\\work\\svn\\incubation\\ttsServer\\Data\\ttsWatchdog.exe" );
res=long(ShellExecute(0, "open", callString2, id, 0, SW_SHOWNORMAL));
And still, the contents of callString and callString2 are the same. Version 2 works, version 1 not.
I´ll look into the len parameter of sprintf_s. But I don´t think that´s it.
Thanks.
Souldrift
modified on Monday, October 5, 2009 5:26 AM
|
|
|
|
|
I made a test. Both version 1 and version 2 work fine on my system.
Of course I had to provide a value for the file std::str variable (and I used different path and executable).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
God, how I hate programming
Thanks again ...
|
|
|
|
|
I found it. What a bugger.
I got my file name from an absolute path like this
string path = wdPath.substr( 0, index+1 );
string file = wdPath.substr( index+1 );
And though 'file' was displayed correctly in the watch, it seems to have contained some invalid sign. Cause like this ...
string path = wdPath.substr( 0, index+1 );
string file = wdPath.substr( index+1, wdPath.size()-index-2 );
... it works.
Cheers
Souldrift
|
|
|
|
|
Hi all,
in SHBrowseForFolder Function when window open its title is "Browse for folder".
please tell me can i change it.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
The SHBrowseForFolder [^] takes in a pointer to a BROWSERINFO[^] structure.
You can assign the lpszTitle of BROWSERINFO and pass the BROWSERINFO to SHBrowseForFolder .
|
|
|
|
|
In BROWSERINFO structur the parameter discription like this
"lpszTitle
Pointer to a null-terminated string that is displayed above the tree view control in the dialog box. This string can be used to specify instructions to the user.
"
this parameter not change the main window title.
please help me.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
LPMALLOC pMalloc;
LPITEMIDLIST pidl;
TCHAR szPath [MAX_PATH];
BROWSEINFO bi = { GetSafeHwnd(), NULL, szPath,
_T("Test title for browse dialog"),
BIF_VALIDATE|BIF_UAHINT|BIF_NEWDIALOGSTYLE|BIF_NONEWFOLDERBUTTON|BIF_RETURNONLYFSDIRS, NULL, NULL };
pidl = SHBrowseForFolder ( &bi );
if ( NULL != pidl )
{
SHGetMalloc ( &pMalloc );
pMalloc->Free(pidl);
pMalloc->Release();
}
here the window title is remain same "Browse for folder",and "Test title for browse dialog" comes above on dir tree.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
You may use the lpfn member of the struct, for instance
int CALLBACK MyCallback(
HWND hwnd,
UINT uMsg,
LPARAM lParam,
LPARAM lpData
)
{
if (uMsg == BFFM_INITIALIZED)
SetWindowText(hwnd, _T("Hi folks"));
return 0;
}
and then
BROWSEINFO bi = {
GetSafeHwnd(),
NULL,
szPath,
_T("Test title for browse dialog"),
BIF_VALIDATE|BIF_UAHINT|BIF_NEWDIALOGSTYLE|BIF_NONEWFOLDERBUTTON|BIF_RETURNONLYFSDIRS,
MyCallback,
NULL
};
pidl = SHBrowseForFolder ( &bi );
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
As you've found out, the lpszTitle member of the BROWSEINFO structure does what it says - changes the text above the tree control, rather than the title.
I'd agree that the variabke name is a bit misleading, but the help text tells the truth.
Maybe make a browsecallbackproc?
The docs say that the first parameter of this callback function is the window of the browese dialog. Could yopu call SetWindowText from there? It passes a BFFM_INITIALIZED message to the proc, so you could change the text very soon.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Thank u very much its really helps me.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|