|
Hi,
I have built an win32 applicaion in which i m using global functions n no classes. I want to open a CFileDialog in the applicaion but i m not able to get CWnd *m_pMainWnd member of the application, which is required to initialize CFileDialog object.
When in Winmain function of my application I write this
/////////////////////////////////////////////////
CWinApp* app=AfxGetApp();
ASSERT(app!=NULL); // app is NULL when I check in Debug window
pWnd=app->m_pMainWnd; // CWnd *pWnd , global variable
//////////////////////////////////////////////////////////////////////
It generates a Debug Assertion Failed message.
Can any one suggest a solution.
I need the CWnd variable for CFileDialg in function and want to pass it to the function instead fo HWND hWnd.
/////////////////////////////////////////////////////////////////////////////
void LoadXmlFile(HWND hWnd)
{
CString strFileName;
char szFilters[]= "XML Files (*.xml)|*.xml";
CString str;
CFileDialog fileDlg(true,0,0,OFN_FILEMUSTEXIST| READONLY,szFilters ,(CWnd*)hWnd );
.....................
}
//////////////////////////////////////////////////////////////////////
I ll appreciate if anyone helps.
Thanx in anticipation.
Cyber Friend
|
|
|
|
|
Cyber Friend wrote: I have built an win32 applicaion in which i m using global functions n no classes
That implies that you are not using MFC, so there will be no CWinApp instantiated in any of your address space. This will also make it tough to implement or use any other MFC based classes. The best alternative I can offer is to look up about the OPENFILENAME struct and the functions GetOpenFileName and GetSaveFileName and use them instead.
Chris Meech
I am Canadian. [heard in a local bar]
The America I believe in has always understood that natural harmony is only one meal away from monkey burgers. [Stan Shannon]
GOOD DAY FOR: Bean counters, as the Australian Taxation Office said that prostitutes and strippers could claim tax deductions for adult toys and sexy lingerie. [Associated Press]
|
|
|
|
|
|
|
In the WinMain function you should use:
<code>AfxSetResourceHandle</code>(hInstance);
CWinApp *pTheApp = new CWinApp; after the InitInstance call and
delete pTheApp; after the message loop.
Avoid doing it with the MFC once you have started in the plain API mood.
"quot capita, tot sententiæ"
rechi+
|
|
|
|
|
First, you must decide if you want to use MFC, or if you do not want to use it.
If you are going to use it, derive a class from CWinApp. Override InitInstance (and any other methods you care to) and create a main window there (and assign it to the m_pMainWnd pointer). By default, CWinApp does not have/create a window for you, so the code you are doing above will not work because m_pMainWnd is NULL. This is desired behavior because you can use CWinApp to create a class for console apps.
If you are not going to use MFC, you need to use the Win32 APIs to initialize and create the dialog. There are some documents in MSDN that should get you started.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Thanx to all of you for ur nice suggestions. I have solved this problem wid the help of a person.
Solution is :
I added this
AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
to Winmain() of my Win32 application n then got CWnd* like this
CWnd* pParentWnd = CWnd::FromHandle(hWnd);
and then passed thi pParentWnd to CFileDialog's constructor n then all worked correctly.
Regards
Cyber Friend
|
|
|
|
|
I'm hanving problems with digest authentication with Microsoft-IIS/5.0
server , does any one have solution for plz ,
i'm waiting ...
|
|
|
|
|
HI,
I want to Minimze the Application to System Tray at click on Close (Crosss) button, I dont want to get it closed on clickking on Close button
Where I can capture the click envent on close button.
How ca I minimize application to system tray.
Regards.
|
|
|
|
|
Handle the WM_CLOSE message..
If ur using a dialog based application u can overide OnClose() function
nave
|
|
|
|
|
|
zahid_ash wrote: I want to Minimze the Application to System Tray at click on Close (Crosss) button, I dont want to get it closed on clickking on Close button
Where I can capture the click envent on close button.
How ca I minimize application to system tray.
WM_SYSCOMMAND for ALT+f4 too!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Help CRY
|
|
|
|
|
Where the WINDOWS stores information about arranging (sorting) order in folders that was assigned in Shell Browser. How to determine or assign new arranging order by using shell functions or other methods. This task in undocumented, but the Shell Browser can do this..
I will be thankful for any information about this. Thank you.
|
|
|
|
|
|
I have Bytes in the following variable "resultArray"
byte resultArray __gc[] = new byte __gc[1];
I need to Take string from this variable with ASCII encoding.
For reference in C# we will do the following to get the string
result = Convert.FromBase64String(resultArray );
Encoding.ASCII.GetString(result ) ;
Whats the corresponding VC++.
|
|
|
|
|
Do u mean ,Converting a HexaDecimal Number into ASCII,
If that is the case , use the following function.
void ConvertToASCII(unsigned char number[],char getChar[],int length)<br />
{<br />
int index;<br />
char capitalLetter[30]= { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};<br />
char smallLetter[30] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; <br />
char numeric[11]={ '0','1','2','3','4','5','6','7','8','9'};<br />
int len;<br />
<br />
for( len = 0 ; len < length;len++)<br />
{<br />
if(number[len] >= 48 && number[len] <=57)<br />
{<br />
if ( number[len] == 48 )<br />
getChar[len] = numeric[0];<br />
else<br />
{<br />
index = number[len] - 48;<br />
getChar[len] = numeric[index];<br />
}<br />
}<br />
<br />
else if (number[len] >= 65 && number[len] <= 90)<br />
{<br />
if ( number[len] == 65 )<br />
getChar[len] = capitalLetter[0];<br />
else<br />
{<br />
index = number[len] - 65 ;<br />
getChar[len] = capitalLetter[index];<br />
}<br />
<br />
}<br />
else if ( number[len] >= 97 && number[len] <= 122)<br />
{<br />
if(number[len] == 97 )<br />
getChar[len] = smallLetter[0];<br />
else<br />
{<br />
index = number[len] - 97;<br />
getChar[len] = smallLetter[index];<br />
}<br />
}<br />
<br />
else<br />
{<br />
getChar[len] = '*';<br />
}<br />
} <br />
return; <br />
}
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
I hope WideCharToMultiByte is the function that ur looking for.
nave
|
|
|
|
|
Yes seems it will do; since im new to this i cant exactle identify what are all the parameters which i need to send.
byte resultArray __gc[] = new byte __gc[1];
Consider i have bytes in the above variable now how can i get my encoded string.
|
|
|
|
|
byte is nothing but unsigned char ,
So the first parameter [in] in my function is resultArray __gc,
Second paramter is output paramter ,
Third paramter is sizeof the resultArray __gc.
Is it clear now ???
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
here is a small example
const wchar_t* pwcTemp = L"Some text\0";
int nLength = _tcslen(pwcTemp );
char* pMultiByte = new char[nLength];
WideCharToMultiByte( CP_ACP, 0, pwcTemp, nLength,pMultiByte, nLength,0,0 );
But I am not familier with the __gc.
in ur case u should replace the pwcTemp with the resultArray
nave
|
|
|
|
|
No way i have to use the format which i have mentioned, Any clues?
|
|
|
|
|
Hi All,
Currently installed MSMQ version and how we can install new version in Windows XP SP2
SaRath
|
|
|
|
|
|
Hi,
I have a program, which has a timer and dialog.
Program purpose is to set the window on top most and active in a specified interval.
Problem is that the dialog is getting on the top most. That is ok.
But not getting activated ( No focus ).
Please see the code:
void CTestSetWPosDlg::OnTimer( UINT nIDEvent )
{
CDialog::OnTimer( nIDEvent );
SYSTEMTIME stSystemTime;
GetLocalTime( &stSystemTime );
CString csTime;
csTime.Format( "%d:%d", stSystemTime.wMinute, stSystemTime.wSecond );
SetWindowText( csTime.operator LPCTSTR());
SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS );
SetActiveWindow();
}
Krishnakumar
|
|
|
|
|
you should get the return value of SetActiveWindow.if the return value is null,it means failure.then you can call GetLastError and get the error code.you can use the error lookup tool to get the reason for the failure.
|
|
|
|
|