|
|
OnDisplay()<br />
{<br />
char str[MAX_PATH ];<br />
BROWSEINFOA lpbi;<br />
lpbi.hwndOwner=this->m_hWnd;<br />
lpbi.pszDisplayName=str;<br />
lpbi.lpszTitle="Test";<br />
lpbi.ulFlags=0;<br />
CoInitialize(NULL);<br />
OleInitialize(NULL);<br />
SHBrowseForFolder(&lpbi);<br />
<br />
<br />
}
For some reason the call to ShBrowseForFolder crashes .
|
|
|
|
|
I found something like this,
and it works for me...
CoInitialize(0);
BROWSEINFO bi;
char cc[MAX_PATH];
bi.hwndOwner=m_hWnd;
bi.pidlRoot=0;
bi.pszDisplayName=cc;
bi.lpszTitle="";
bi.ulFlags =0;
bi.lpfn =0;
bi.iImage=0;
LPITEMIDLIST p;
p=SHBrowseForFolder(&bi);
if(!p)
return;
SHGetPathFromIDList(p,cc);
SetDlgItemText(IDC_E_PATH,cc);
IMalloc *pm;
SHGetMalloc(&pm);
pm->Free(p);
|
|
|
|
|
Thank you for the help
I wasnt doing this
bi.pidlRoot=0;
hence the crash .
Another question
using LPITEMIDLIST p how do I get the FilePath ?
|
|
|
|
|
act_x wrote:
Can the usual CFileDialog class serve this purpose ? .
Yes, but SHBrowseForFolder() is going to be easier.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello,
Setting the edit box text via SetWindowText does not work inmediatelly if you set it from one of the handlers of your dialog. Instead, the update will happen only after the handler ends its run.
void CDemoDlg::OnNewBnClicked()
{
m_newBtn.EnableWindow(FALSE);
GetDlgItem(IDC_STATUS_EDIT)->SetWindowText("New"); <font color=#AA0000>
...
<font color=#AA0000>
...
m_newBtn.EnableWindow(TRUE);
}
If I replace the Edit Control with a static control, the text is updated inmediatelly. (Before the button control is enabled)
I guess that the answer is the use of SendMessage and PostMessage.
Is there a way to update an edit control inmediatelly and not wait till the handler ends?
Any hint? (I need an edit control there)
Another example:
void CDemoDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
HWND hwnd = pScrollBar->GetSafeHwnd();
if (hwnd == m_mainCursorSliderCtrl.GetSafeHwnd())
{
int pos = m_mainCursorSliderCtrl.GetPos();
if (pos != m_mainCursorPosition)
{
CString text;
m_mainCursorPosition = pos;
text.Format("Main:%d", pos)
GetDlgItem(IDC_STATUS_EDIT)->SetWindowText(text);
GetDlgItem(IDC_STATUS_STATIC)->SetWindowText(text);
UpdateListControlData();
}
}
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
The list control and IDC_STATUS_EDIT is update only when the slider-bar stops, while the IDC_STATUS_STATIC is updated on real-time.
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
Is it possible to create nested directories using CreateDirectory()?How exactly?
|
|
|
|
|
|
Hi all,
I've written a program (with bits taken out of various Articles on here) which captures the screen and then saves the screen shot as a bitmap.
I've got this working as a standalone executable however I now need to be able to do this from within a dll. The problem I've got is that as soon as I get to the line in the dll where I use a pointer to the CWnd* from the calling application I get a crash. At first I thought it was case of the CWnd pointer going out of focus so I tried GetSafeWnd but I get the same error (the reason I'm passing this in is that I need it for the creation of my dc and also to get the screen size).
Does anyone know what I'm doing wrong and how to correct it (I'm using MS VC++ 6.0)
TIA,
Andy
|
|
|
|
|
managed to solve this by not passing a CWnd pointer into the dll. WHat I've done is to call GetDesktopWindow within the dll, this returns a valid CWnd* which I can use
|
|
|
|
|
The crash occurs as thread local storage is used for CWnd objects. It is possible to pass the windows HWND (using CWnd::GetSafeHwnd() ) and then wrap that up in a new CWnd object within the DLL if desired.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Hi,
i'm currently working on a game trainer. My problem is, that i want to protect it against
Spy-Software like spy XP, ArtMoney and other trainer cheating software. Also i want to protect it from beeing disasemmbled. Does anyone has some piece of code that can detect if a Spy-Software try to open my trainer. I'm currenty using the FinWindow to close a spy-prog. But i have to know the window title. I want to protect my prog against every spy-software - against every version and not with knowing the window title. My aim is it to detect if another process hooks my trainer or tries to cheat my trainer. Anyone has a source or link?
i forget: i use C++!
Thx!
TJ20
JR20
|
|
|
|
|
JR20 wrote:
Also i want to protect it from beeing disasemmbled.
It will always be possible to reverse engineer any executable if you have access to it.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Thx for your reply!
Yes, but you can make it more complicated. I not want to protect it against "real" hackers. Only against hobby proggers. Does anyone has a idea how to prevent spy xp to cheat my trainer? Or to detect any spy-software? Thx!
JR20
|
|
|
|
|
I need to be able to list all of the registry values in a specific key.
|
|
|
|
|
You use RegEnumValue[^]
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Hi,
I try to create a dialog where user can select folders or files, these ones would be written in a configuration file, till here, no problem.
But, I want that these files, when added, were be displayed their icons on the dialog and when the user opens the dialog again, can view these folders or files and can add or delete them.
So, what I want is the app read the text file and display the icons, is it possible, or have I to resign myself with display the path with text only? Is there some function to do this?
Thanks a lot!
|
|
|
|
|
Use SHGetFileInfo() . Look at the hIcon and iIcon members of the SHFILEINFO struct.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks!!!! This is what i'm looking for!
|
|
|
|
|
Hi all,
I'm trying my first unicode application. Now I have the problem how to convert from CString (the unicode variant) to std::string.
Anyone has a hint?
Thanks,
Patrik
|
|
|
|
|
|
Hi,
thanks for the link - but I'm still a VC6 user ;-(
Do you have a better idea??
Thanks,
Patrik
|
|
|
|
|
First of all:
1) CString --> this is a string wrapper class, which is part of the Microsoft Foundation Classes(MFC).
2) std::string --> this is a Standard C++ Class wrapping a char string. It is part of the Standard Template Library, or STL.
The conversions between them are:
<br />
CString cs("Your text");<br />
std::string s((LPCTSTR)cs);<br />
<br />
std::string s("Your text");<br />
CString cs(s.c_str());<br />
SkyWalker
|
|
|
|
|
Thats clear - but try that within an unicode environment!
my last idea was that:
std::string result;
int i;
char *pmb = (char *)malloc( sizeof( char ) );
for (int j = 0; j < theString.GetLength()+1; j++)
{
i = wctomb( pmb, theString.GetAt(j) );
if (i != 1 && i != -1)
result.append(pmb);
}
But no success ;-(
|
|
|
|
|
Try to use ANSI-To-UNICODE and UNICODE-TO-ANSI string conversions:
<br />
char *ansistr = "Your text";<br />
int a = lstrlenA(ansistr) + 1;<br />
BSTR unicodestr = SysAllocStringLen(NULL, 2*a);<br />
MultiByteToWideChar(CP_ACP, 0, ansistr, a, unicodestr, a);<br />
AfxMessageBox(CString(unicodestr), MB_OK, 0); :-)<br />
SysFreeString(unicodestr);<br />
and
<br />
BSTR unicodestr;<br />
SomeFunction(unicodestr);<br />
int a = SysStringLen(unicodestr) + 1;<br />
char *ansistr = new char[a];<br />
WideCharToMultiByte(CP_ACP, 0, unicodestr, -1, ansistr, a, NULL, NULL);<br />
AfxMessageBox(ansistr, MB_OK, 0); <br />
delete[] ansistr;<br />
SysFreeString(unicodestr);<br />
SkyWalker
|
|
|
|