|
|
Thank you Michael
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Hi,
I've posted a meesage like this about a month ago on this forum, but I didn't get any satisfacting responses; so I'll try again.
I've created a setup prject, with the "Setup Projects" template, this is for an MFC C++ application. The installer works great, but I want to let the user determine wether he wants a shortcut placedn on his desktop\start menu. So I added a new dialog to my project, containing three checBoxes.
But after having done this, I wanted to a some kind of 'link' between checking a checkbox and the creation of a shortcut. If already inserted the shortcuts in the FileSystem tab, but I don't know how to script the decision correctly (I know C and its derivates, not Basic!). I've already looked at the MSDN, but I can't find a nice answer!
The properties of the checkbox are these: (in the user interface editor!) (I haven't included irrelevant properties (irrelevant to me))
CheckBox1Property : CHECKBOXC1
CheckBox1Value : Unchecked
|
|
|
|
|
Hi
You do not have to script anything to do this.
What You do is, create the shortut in the installation project as normal, and in the "Condition" property of the sourtcut write "CHECKBOXC1 = checked".
That's it.
|
|
|
|
|
Thanks, I'll try it
I didn't know it was that simple!
|
|
|
|
|
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
|
|
|
|
|