|
I jsut tried your solution, but it isn't working, although I entered the text (without the double quotation amrks in the conditions field). I tried it with a capitalized c in checked, and put transitive on true and false.
No combination of it seemed to worrk --> the shortcut was created every time I tried the installer (it should only be created if the checkbox is checked).
|
|
|
|
|
|
Hi
You want to open a folder with a return of a path?
or
Open a folder to make changes to it's attributes?
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
If you're talking about opening Window's folder selection dialog, take a look at the ::SHBrowseForFolder() API.
You'll need to include the <Shlwapi.h> header file.
I Dream of Absolute Zero
|
|
|
|
|
Yeah. I really want this function.
But i found this dialog is not similar with use FileDialog(),When i use FileDialog to open a dialog to open a file.
|
|
|
|
|
Grrrr wrote:
But i found this dialog is not similar with use FileDialog(),
Yeah, I know that using the Windows API folder function is not as easy as using MFC's CFileDialog.
However I did recall something here on CP, so a little searching has uncovered
This:[^]
Its a C++ wrapper for the ::SHBrowseForFolder API.
I havent used it myself, but I probably will try it out in my next project.
I Dream of Absolute Zero
|
|
|
|
|
try this class:
------------------------------
DirDialog.h
class CDirDialog
{
public:
CDirDialog();
virtual ~CDirDialog();
BOOL DoBrowse(CWnd *pwndParent = NULL);
CString m_strWindowTitle;
CString m_strPath;
CString m_strInitDir;
CString m_strSelDir;
CString m_strTitle;
int m_iImageIndex;
BOOL m_bStatus;
private:
virtual BOOL SelChanged(LPCSTR lpcsSelection, CString& csStatusText) { return TRUE; };
static int __stdcall CDirDialog::BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
};
------------------------------
DirDialog.cpp
// Callback function called by SHBrowseForFolder's browse control
// after initialization and when selection changes
int __stdcall CDirDialog::BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) {
CDirDialog* pDirDialogObj = (CDirDialog*)lpData;
if (uMsg == BFFM_INITIALIZED) {
if (!pDirDialogObj->m_strSelDir.IsEmpty() )
::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPCTSTR)(pDirDialogObj->m_strSelDir));
if (!pDirDialogObj->m_strWindowTitle.IsEmpty() )
::SetWindowText(hwnd, (LPCTSTR) pDirDialogObj->m_strWindowTitle);
}
else
if (uMsg == BFFM_SELCHANGED) {
LPITEMIDLIST pidl = (LPITEMIDLIST)lParam;
char selection[MAX_PATH];
if (!::SHGetPathFromIDList(pidl, selection) )
selection[0] = '\0';
CString csStatusText;
BOOL bOk = pDirDialogObj->SelChanged(selection, csStatusText);
if (pDirDialogObj->m_bStatus )
::SendMessage(hwnd, BFFM_SETSTATUSTEXT , 0, (LPARAM)(LPCSTR)csStatusText);
::SendMessage(hwnd, BFFM_ENABLEOK, 0, bOk);
}
return 0;
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDirDialog::CDirDialog() {
m_bStatus = FALSE;
}
CDirDialog::~CDirDialog() {
}
BOOL CDirDialog::DoBrowse(CWnd *pwndParent) {
if (!m_strSelDir.IsEmpty()) {
m_strSelDir.TrimRight();
if( m_strSelDir.Right(1) == "\\" || m_strSelDir.Right(1) == "//" )
m_strSelDir = m_strSelDir.Left(m_strSelDir.GetLength() - 1);
}
LPMALLOC pMalloc;
if (SHGetMalloc(&pMalloc) != NOERROR )
return FALSE;
BROWSEINFO bInfo;
LPITEMIDLIST pidl;
ZeroMemory((PVOID)&bInfo, sizeof(BROWSEINFO) );
BOOL bIsRepository(m_strInitDir.IsEmpty() );
if (!m_strInitDir.IsEmpty() ) {
OLECHAR olePath[MAX_PATH];
ULONG chEaten;
ULONG dwAttributes;
HRESULT hr;
LPSHELLFOLDER pDesktopFolder;
//
// Get a pointer to the Desktop's IShellFolder interface.
//
if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder) ) ) {
//
// IShellFolder::ParseDisplayName requires the file name be in Unicode.
//
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
m_strInitDir.GetBuffer(MAX_PATH),
-1,
olePath,
MAX_PATH);
m_strInitDir.ReleaseBuffer(-1);
//
// Convert the path to an ITEMIDLIST.
//
hr = pDesktopFolder->ParseDisplayName(NULL, NULL, olePath, &chEaten, &pidl, &dwAttributes);
if (FAILED(hr) ) {
pMalloc->Free(pidl);
pMalloc->Release();
return FALSE;
}
bInfo.pidlRoot = pidl;
}
} else
bInfo.pidlRoot = NULL;
bInfo.hwndOwner = pwndParent == NULL ? NULL : pwndParent->GetSafeHwnd();
bInfo.pszDisplayName = m_strPath.GetBuffer(MAX_PATH);
bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open" : m_strTitle;
bInfo.ulFlags = BIF_RETURNFSANCESTORS
| BIF_RETURNONLYFSDIRS
| (m_bStatus ? BIF_STATUSTEXT : 0 );
bInfo.lpfn = BrowseCtrlCallback; // address of callback function
//bInfo.lpfn = NULL;
bInfo.lParam = (LPARAM)this; // pass address of object to callback function
if ((pidl = ::SHBrowseForFolder(&bInfo)) == NULL)
return FALSE;
CString strTmp(m_strPath);
m_iImageIndex = bInfo.iImage;
if (::SHGetPathFromIDList(pidl, m_strPath.GetBuffer(MAX_PATH)) == FALSE) {
pMalloc->Free(pidl);
pMalloc->Release();
if (!bIsRepository)
return FALSE;
//Chapuza, para que se pase el nombre de la maquina solamente, sin ningun directorio
m_strPath.Format(_T("\\\\%s"), strTmp.GetBuffer(MAX_PATH) );
m_iImageIndex = bInfo.iImage;
return TRUE;
}
m_strPath.ReleaseBuffer();
pMalloc ->Free(pidl);
pMalloc ->Release();
return TRUE;
}
---------------------------------
Use:
CDirDialog dirDialog;
dirDialog.m_strInitDir = _T(""); //the root dir
dirDialog.m_strSelDir = //Initial select dir
dirDialog.m_strTitle.LoadString(IDS_STRING_SELECT_DIR); //title
dirDialog.m_strWindowTitle.LoadString(IDS_STRING_SELECT_REPOSITORIO); //title window
if (dirDialog.DoBrowse( this ) ) {
dirDialog.m_strPath; //Here is the select dir
}
-----------------------------------------------------
|
|
|
|
|
Hi,
I have already asked you yesterday
but I didn't explain my problem clearly
I have dialog based application.
And at any time when I press some keyboard key
over the window it makes sound (Some default window sound)
Is here any way how to turn it off from program?
but I cannot mute the speakers
in my application. It's already playing different audio
and problem is that I am playing audio and whan key
is pressed the key sound is mixed with my audio.
Key sound is not bothering me in time when
is nothing played - it doesn't matter in that time.
Thanx
Viliam
viliam
|
|
|
|
|
Please help us understand!
Do you mean when your application "HAS FOCUS" and you type the os or shell makes a sound?
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Yes, my window has focus and I press some key.
It's for example empty dialog box and
key has no effect for it.
But system play some short sound.
Anyway I cannot find where to switch
this in Windows XP options at least.
(for all programs)
viliam
|
|
|
|
|
I just received a copy of a demo fro vs.net2003 and happily installed it to measure its performance for vc++. As a big surprise vc.net 2003 is quite a bit slower! For a simple bench I used a mandelbrot loop (ie not easily optimized away). I also tested simple empty nested for-loops, these are optimized away in vc6 but not in vc.net 2003.
Is there others who have seen this "speed reduction"? Is this a real problem or something that is in the demo version only?
|
|
|
|
|
The optimization level of VS .NET 2003 is much higher than in VC++ 6. It takes more time to do that. You can take off the optimizations altogether, and the code will compile & link quickly, but will run more slowly.
Compilation/linking speed, however, shouldn't become a big issue until you move to BIG applications (Millions and millions of lines of code). At that point, you'd consider modularizing the application to make it's development easier, and this step would again reduce the time required to build your app.
So even though it complies/links a bit slower, it should't pose a big problem. If you run on a tight time schedule and can't spare time for the compilations, then write bug-free code in the first place so you don't need to do test builds for your app.
As a comparison, compiling the Quake Engine took about 3 minutes with my VC++ .NET 2003. Not much considering how big the engine is...
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Sorry I was unclear! The actual compilation went ok, pretty fast and actually produced smaller exe. What is the problem is the actual execution! Executing the release build of my mandelbrot test took ~3 times longer for the vc.net 2003 version. Also when running empty for-loops it didn't seem to optimize away those.
Any clues?
|
|
|
|
|
The first-time execution of any built program in VS .NET 2003 is always slow. If you open a project, build it, then execute/debug it, it will take ages. The next run is already a whole lot faster.
To test the actual execution speeds, build a EXE with VC++ 6, then with VC++ .NET, and then run both applications from the system shell/Explorer instead of inside the Visual Studio.
This will give you a clear picture of how fast the applications are actually executing. I bet that the VC++ .NET version will run faster from the shell than VC++ 6 version does.
I don't know about the empty for-loops, or the reason why it doesn't optimize those. Perhaps the optimization assumes that nobody is stupid enough to write empty loops ?
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I really need to learn telling people all facts! Yes, I ran the apps from the shell! The mandelbrot test produced the timing: vc.net 4.196s and vc6.0 1.482s
Still I don't know if this is a real problem or just a demo "feature"!? If it's real it's no good!
The code:
// test1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#define WIDTH 100
#define HEIGHT 100
#define ITER 10000
void mandel()
{
double x,y;
double xstart,xstep,ystart,ystep;
double xend,yend;
double z,zi,newz,newzi;
int i,j,k;
xstart = -2;
xend = 2;
ystart = -2;
yend = 2;
/* these are used for calculating the points corresponding to the pixels */
xstep = (xend-xstart)/WIDTH;
ystep = (yend-ystart)/HEIGHT;
/*the main loop */
x = xstart;
y = ystart;
for (i=0; i<height; i++)
="" {
="" for="" (j="0;" j<width;="" j++)
="" z="0;
" zi="0;
" (k="0;" k<iter;="" k++)
="" *="" z^2="(a+bi)(a+bi)" =="" a^2="" +="" 2abi="" -="" b^2=""
="" newz="(z*z)-(zi*zi)" x;
="" newzi="2*z*zi" y;
="" break
="" if(((z*z)+(zi*zi))=""> 4)
{
// no break here always calculate everything!!!
}
#endif
}
x += xstep;
}
y += ystep;
x = xstart;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
unsigned long t;
t = ::GetTickCount();
mandel();
t = GetTickCount() - t;
printf("%u", t);
return 0;
}
|
|
|
|
|
hi...i have a question..
i am using SDI Doc/View arch.
now i dialog that comes up before anything else appears on the screen..
now if the user presses cancel on this dialog..the open file dialog should apprear...
this open dialog is the same on that MFC already gives uswhen we create the SDI proj using AppWizard..
now how can i make this happen???
somethin like making the File->Open menu click through the codes??so that it will open up the Open File Dialog???
i dont really know what am i supposed to do...
hope you can help...
tks a lot...
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
In the app have you placed your dialog and calls before the call to the sdi mainframe?
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
huh???
i dont get it....
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
What don't you get?
In the App like CMyProjectApp
Did you place the dialog there or in the Frame?
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
HUH?????????
what dialog?????
there is no dialog......
the question is can i CALL the dilog that comes up when we click : File->Open from the menu that is already given in SDI app by MFC...
that very same open dialog which is made by MFC AppWiard and put inSDI app's menu...
can i call it from my program WITHOUT actually clicking : File->Open
can i call the menu itself from my program without clicking it??
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Sure you can!
First allow me to say it is a good question, I just did not understand what you wanted. Most of the guys on this site are pro's and have been programming for years, so we sort of understand what we are talking about, and use the ART of the language itself to communicate. This can lead to problems.
Now:
If you look at your IDR_MAINFRAME-> FILE OPEN property you will see the resource ID -> ID_FILE_OPEN right?
Just for fun let's go to the toolbar and create a new button
and select the properties for the new button ID_FILE_OPEN
compile the project and run it.
see the new button calls File open right?
So how does it do it is your question and can I make the call directly, right?
Yes you can
In the app under initistance
enter this at the bottom ject before retrun TRUE;
OpenMyFile();
Now in the app create a new member function
void CMyCoolApp::OpenMyFile()
Enter this code inside your new function.
{
OnFileOpen();
}
It should look like this now.
void CMyCoolApp::OpenMyFile()
{
OnFileOpen();
}
There you go!
Best Wishes and Happy Holiday's,
ez_way
I received your private message and here is a response to it!
HUH?????????
what dialog?????
there is no dialog......
>> The file open box is a dialog!
the question is can i CALL the dilog that comes up when we click : File->Open from the menu that is already given in SDI app by MFC...
>> Yes I told you how above!
that very same open dialog which is made by MFC AppWiard and put inSDI app's menu...
>> I understand
can i call it from my program WITHOUT actually clicking : File->Open
can i call the menu itself from my program without clicking it??
>> Yes!
|
|
|
|
|
How I click the button and then it will open the program @ file. Example: Window Explorer, Microsoft Work....
|
|
|
|
|
Best Friend wrote:
button
What button? Your button, my button, everyone's button?
Best Friend wrote:
program @ file
What's program @ file? Is this a new computer term I've yet to grasp?
---
Your question is not quite coherent, my Best Friend, but are you by any chance
talking about using the ::ShellExecute() API to launch the windows program associated with the given filename?
If so then your question has been answered.
I Dream of Absolute Zero
|
|
|
|
|
Hi guys,
I have just learned how to create a dialog-based application with mutiple child dialogs. So far it works fine, however, in Debug window, I always received memory leak warning upon the app exit :
Detected memory leaks!
Dumping objects ->
childdlg.cpp ........
I am just wondering what could cause this?
Basically, say, I have a parent dialog class, say CMyDlg and a child dialog class called CChildDlg. The child class was included on the top of MyDlg.cpp file
#include <ChildDlg.h>
CChildDlg *vChildDlg;
I embedded the child dialog into parent by putting the following codes in OnInitDialog() of the parent's cpp file, MyDlg.cpp.
vChildDlg = CChildDlg();
vChildDlg->Create(IDD_CHILD_DIALOG, this);
vChildDlg->SetWindowPos(this, 20, 20, 50, 50);
vChildDlg->ShowWindow(SW_SHOW);
That looks pretty straight forward. But why on the app's exit, it causes memory leak? Is there something I need to do perhaps in the parent and child class' destructor?
Thanks
|
|
|
|
|
the line
vChildDlg = CChildDlg();
creates an instance of CChildDlg.
You need to delete this instance of vChildDlg when the app exits.
|
|
|
|
|