|
I have a requirement (in a dialog based application) to show the system menu on click of a button, placed somewhere in the middle of client area.
So I tried this code.
void CMenuTestDlg::OnMenuButton()
{
CMenu * sysMenu = GetSystemMenu(FALSE);
if(sysMenu != NULL){
sysMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, 40,40, this);
}
}
Using this, the menu appears but it doesnt function, i.e, I select minimize or close menu item nothing happens.
Am I missing anything here? Gurus Please help me..
Thanks in advance,
Subrahmanyam
|
|
|
|
|
TrackPopupMenu seems not to work well with system menus. Try this workaround:
void CMenuTestDlg::OnMenuButton()
{
CMenu * sysMenu = GetSystemMenu(FALSE);
if(sysMenu != NULL){
int menuID=sysMenu->
TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON |TPM_RIGHTBUTTON |
TPM_NONOTIFY | TPM_RETURNCMD, 40,40, this);
if(menuID){
SendMessage(WM_SYSCOMMAND,menuID,0);
}
}
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Man,
You rock!!
Thanks for the help. Its working great.
regards,
Subrahmanyam.
|
|
|
|
|
When user selects command from system menu opent by usual way, your dialog gets WM_SYSCOMMAND message. When command is selected from the menu created by OnMenuButton(), dialog gets WM_COMMAND message. Play with Spy++ to find the way to handle this.
|
|
|
|
|
Alex,
Thanks for your reply and the pointer to solution.
Joaquín has posted code and made my day
Thanks to both of you,
Subrahmanyam.
|
|
|
|
|
Can somebody help me.
What is the most elegant way to get a uniq filename under windows.
|
|
|
|
|
GetTempFileName is customarily used for that purpose.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a lot this must be the solution.
Jørgen Granborg
DK
|
|
|
|
|
Hi , i am working on a project where i will be needing this plugin kinda library support , so if any one of u have worked or does know the place from where i can get any kinda help then please do let me know.
thanks
gracias
gracias carol
|
|
|
|
|
What's the politically (and standards) correct method these days?
[geek]
I have strings that look like this: "d20", "5d6", etc. I need to suck out the optional prefix number, and the suffix number.
[/geek]
I will be using std::string and the rest of the standard library, and will be avoiding MFC entirely.
Any suggestions? istringstream?
J
May the bear never have cause to eat you.
|
|
|
|
|
Regular expressions seem to be called for here. Take a look at Boost.Regex++[^].
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
If the pattern was more complicated, I would agree. But since it's just [0-9]?d[0-9] I figured I could do it manually and save the hassle of figuring out Boost.
Would you recommend using Boost for something so simple?
J
May the bear never have cause to eat you.
|
|
|
|
|
Well, maybe regexps are a little overkill for this task, but it depends on how confident you are about this format not changing in the future. Anyway, if you're sure this won't change and don't want to mess with regexps, I think sscanf is your best ally here:
#include <stdio.h>
#include <stdlib.h>
bool my_precious_parser(const char* str,int& prefix,int& suffix)
{
char str_prefix[1024]="0",str_suffix[1024];
if(
sscanf(
str,
"%[012345689]d%[0123456789]",
str_prefix,str_suffix)!=2 &&
sscanf(
str,
"d%[0123456789]",
str_suffix)!=1){
return false;
}
prefix=atoi(str_prefix);
suffix=atoi(str_suffix);
return true;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello all,
(In a MDI-project) I've a statusbar defined in ChildFrm and I want to be able to set its text in the Doc or View. I've tried some ways (ending in using SetPaneText), but I keep getting assert errors. The code is based on the starting point as delivered from the Wizard, and then use the MainFrm statusbar code in the ChildFrm.
If I'm using the 'general' statusbar (in MainFrm) I succeed, but thats not what I want.
So: How to I access the statusbar in the childframe via xxxDoc.cpp or xxxView.cpp?
Thanks in advance,
EiSl
|
|
|
|
|
You could create a public function in your CMainFrame to do the changes and call that function from your doc or view..
Rob
|
|
|
|
|
Hello
I am quite new to the CMonthCalControl (I am working with VC7). Is there a simple way to give it a 'multirow' (multi columns) 'shape', i mean a simple way in order to show not only one 'calendar box' but, say, 3x4 month boxes all at once?
I suppose i could get that result creating an array of controls, right?
Thanks in advance for any help/tip/info!
best regards
|
|
|
|
|
Not really (unless it has been enhanced lately). I have tried to do this. You could create multiple controls, but selection would not work across them and you will have problems with sizing.
I have published a control here on CP which does this and much more. You can find it at:
http://www.codeproject.com/miscctrl/minicalendar.asp[^]
|
|
|
|
|
thank you very much
i'll check your code asap, looks really great!
anyway i was hoping the CMonthCalCtrl could do that
best regards
|
|
|
|
|
dear all,
how to check the existence of a directory using mfc or api?
thanx
|
|
|
|
|
try to change the Dir by using
_chdir(const char* dirName) function
if the return value is -1 ,that means die not exist,else u can move forward your dir is there....
~~~~Code the Dreams~~~~~
|
|
|
|
|
Hi..
You can use CFileFind class
1)construct a CFileFind Object
2)Search the name of the directory using CFileFind::FindFile("DirNamr",0)
3)Call CFileFind::FindNextFile
4)if the search is successfull use CFileFind::IsDirectory() to make sure thet
the found file is a folder not a file.
|
|
|
|
|
Use PathIsDirectory function.
You need to include shlwapi.h and link it with shlwapi.lib
Cheers
Kannan
|
|
|
|
|
#include <io.h>
inline bool dir_exists(const char* str)
{
return _access(str,0)==0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
This way works pretty well, and handles the odd case where the "directory" is really a file:
bool DoesDirectoryExist(LPCTSTR inputPath)
{
bool bRet = false;
DWORD dwRc = ::GetFileAttributes(inputPath);
if (dwRc == 0xFFFFFFFF)
{
bRet = false;
} else if(dwRc & FILE_ATTRIBUTE_DIRECTORY)
{
bRet = true;
} else
{
bRet = false;
}
return bRet;
}
Even a broken clock is right twice a day.
|
|
|
|
|
hai,
We customized the default open dialog by deriving the class from
cfiledialog . These are the issues that we faced.
Issues:
1. How to handle the default messages in cfiledialog class?
2. In Win'2000 & above, we tried to change the listview style to
LVS_REPORT using Modifystyle method The style is changed, but the files and
column headers are not displayed.
3. In Win'98, how to remove the separator in toolbarwindow32.
Please give me the solution as early as possible.
sureshb
sujtha
|
|
|
|