|
or see here
<br />
double y = 1230.01;<br />
CString strxx;<br />
strxx.Format("%lf", y );<br />
MessageBox(strxx);<br />
whitesky
|
|
|
|
|
Hi,
The below code for cfiledialog is have some problem. the problem is when i
press open many times the file dialog box opens ,but sometimes ( at any time ) when file dialog is open and if i press some starting character to select particular file ,the whole application closes automatically..
myclass::OnOpen() {
CFileDialog dlg(TRUE);
Sleep(50);
if (dlg.DoModal() == IDOK) {
l_strFileName = dlg.GetPathName();
MessageBox(l_strFileName);
filepath2 = (char *) (LPCTSTR) l_strFileName;
m_select.ShowWindow(SW_HIDE);
m_start.ShowWindow(SW_SHOW);
m_ed.SetWindowText(l_strFileName);
} }
Manjunath S
GESL
Bangalore
|
|
|
|
|
Manjunath S wrote: Sleep(50);
What's this for? A gratuitous Sleep() is usually an indication of something gone wrong.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi ,
If i remove sleep then also iam getting same error.
Manjunath S
GESL
Bangalore
|
|
|
|
|
Then you're giving the gratuity somewhere else.
|
|
|
|
|
can i get any sample code regarding ,to open fileopen dialog box
Manjunath S
GESL
Bangalore
|
|
|
|
|
Exactly what steps are you taking to reproduce the problem? Does it happen with every folder, or one in particular? What character are you typing? Is Enter/Return clicked? Does the same thing happen with GetOpenFileName() ?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
In every folder iam facing this problem,but not every time . once in while (frequency is 1 time for 20 times trying)my whole application closes....
Manjunath S
GESL
Bangalore
|
|
|
|
|
|
Manjunath S wrote: once in while (frequency is 1 time for 20 times trying)my whole application closes....
You've got problems elsewhere that are manifesting at the point in which you are using CFileDialog . This code should run 20+ times with no troubles:
CFileDialog dlg(TRUE);
if (dlg.DoModal() == IDOK)
AfxMessageBox(dlg.GetPathName());
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Just an FYI since I don't think these issues are causing this problem (at least not directly) ...
1) Manjunath S wrote: Sleep(50);
Chances are very high that if you are calling Sleep, something is wrong with your design. This is almost always the case when done in GUI code (as is the case here).
2) Manjunath S wrote: filepath2 = (char *) (LPCTSTR) l_strFileName;
LPCTSTR is defined as (const TCHAR*). Aside from the fact that the cast above won't work properly in a UNICODE build, it isn't want you want anyway. You aren't showing what you use filepath2 for, but I'm guessing you will either want it as a CString itself, a List/Array of CStrings, or don't need it at all.
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
|
|
|
|
|
Hi,
1.I deleted sleep
2.I need to pass filepath2 as a char* to a function in DLL.
Now the Modified code looks like this ...
void Upload::OnSelect()
{
CFileDialog upload(FALSE);
if(upload.DoModal() == IDOK) {
l_strFileName2 = upload.GetPathName();
MessageBox(l_strFileName2);
/* where filepath3 is a global char* variable */
filepath3 = (char *) (LPCTSTR) l_strFileName2;
m_start.ShowWindow(SW_SHOW);
m_select.ShowWindow(SW_HIDE);
m_edt.SetWindowText(l_strFileName2);
}
}
The above code problem is CfileDialog and whole application closes automatically (once in 18-20 times of Onselect is clicked) .The application closes when i try to select filename in filedialog using keyboard charater(i.e filename first character) )..
Thanking You
Manjunath S
GESL
Bangalore
|
|
|
|
|
Manjunath S wrote: 2.I need to pass filepath2 as a char* to a function in DLL.
Now the Modified code looks like this ...
And the DLL method doesn't take a const char*? If that is the case, what you are doing is still a problem. You are casting away the const on a CString object's private data (which you have no control over). Basically, if the CString object decides to clean up or allocate a bigger block, your pointer is out in the weeds. Try this:
char filepath3[_MAX_PATH] = {0};<br />
void Upload::OnSelect()<br />
{<br />
CFileDialog upload(FALSE);<br />
<br />
if(upload.DoModal() == IDOK) <br />
{<br />
l_strFileName2 = upload.GetPathName();<br />
MessageBox(l_strFileName2);<br />
<br />
strncpy(filepath3, l_strFileName2, _MAX_PATH);<br />
m_edt.SetWindowText(l_strFileName2);<br />
}<br />
}
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
|
|
|
|
|
why do you use Sleep?
whitesky
|
|
|
|
|
Are there any functions available to set the language used for menus/dialogs once a MUI is installed?
The user would manually configure this via: control panel -> regional & language options -> languages tab
Microsoft calls this the UI language and documents functions (GetSystemDefaultUILanguage, GetUserDefaultUILanguage) to get the value, but nothing to set it:
www.microsoft.com/globaldev/reference/localetable.mspx
Thanks for any help
|
|
|
|
|
Hi,
I have created MFC SDI application. I see the title as "Untitled App" after execution. How to change it to the desired one?
I don't see any caption in the form's properties. I have changed the caption
in AboutDialog, but that doesn't help to change to caption of the application.
Thank you.
Harsha
|
|
|
|
|
Turn off the FWS_ADDTOTITLE style in the CFrameWnd
|
|
|
|
|
Note that removing the FWS_ADDTOTITLE style (do in in pre-creation of the CMainFrm window) will only prevent the "untitled" part from appearing - it prevents the document name from going into the title bar.
There is a string in the string table that is used to create the static portion of the caption used in the title bar. Try changing that string to the desired text.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi,
with reference to the article by "Zoran M. Todorovic"--"A Visual Framework:Controls,tabs and splitters",I have created an application with the help of this article.There are 2 tabs on my main window(SDI based MFC-VC++ dot Net-2003 app),and I would like to switch between the two using the main menu,some option like-"Switch:tab1,tab2 etc".If the user clicks on Switch,he has the option of selecting either tab1 or tab-2.
The corresponding tab should come to focus on selection from the menu.
I would be extremely grateful if any one could help me on this.
Thank You very much.
|
|
|
|
|
/*
I'm managing numerous controls as CMyObject for multiple pages in multiple documents (Not CDocument). The PageArrays are allocated on the heap and then placed in the DocArray using "Add". Then the CMyObjects are allocated on the heap and placed in the MyObjectArray using the same. Each document gets some pages, and each page has some controls. I'm using the following abomination to mimic a three dimensional array using the MFC type safe collections...
*/
// Appears to work
typedef CTypedPtrArray<CObArray,CMyObject*> MyObjectArray;
typedef CTypedPtrArray<CObArray,MyObjectArray*> PageArray;
typedef CTypedPtrArray<CObArray,PageArray*> DocArray;
DocArray m_DocArray;
/*
Now, I am trying to provide an object map for each page in each document for quick access to those same CMyObject controls. I am attempting the same except with a map in the third dimension. So it is array, array, then map.
*/
// Does not work. Asserts when trying to add a MyObjectMap
typedef CTypedPtrMap<CMapStringToOb, CString, CMyObject*> MyObjectMap;
typedef CTypedPtrArray<CObArray,MyObjectMap*> PageNameArray;
typedef CTypedPtrArray<CObArray,PageNameArray*> DocNameArray;
DocNameArray m_DocMap;
/*
Attempts to "new" a PageNameArray on the heap and using "add" to put it into the m_DocMap "appears" to work but it asserts when I attempt to index that pointer to add a MyObjectMap allocated on the heap into the PageNameArray...
*/
m_DocMap[nIndex]->Add(pMyObjectMap); // ASSERTS. nIndex is what I'd expect during Trace
/* Also, when I "dot" m_DocMap intellisense does not give me the choices like GetSize().
It gives me
"add()",
"append()",
"copy()",
"ElementAt()",
"GetAt()",
"InsertAt()",
"Operator[]",
"SetAt()",
"SetAtGrow()"
*/
// Does anyone see what I'm doing wrong in the declaration of m_DocMap?
-- modified at 12:21 Wednesday 21st June, 2006
I am coding this using VC++ 2003. I noticed that my intellisense gives me the expected options when I drop the declaration into a VC++ 6.0 project and "dot" the member variable. Not sure if that helps.
|
|
|
|
|
Disregard the question. I discovered my folly.
I thought I had already checked nIndex in a trace but it turns out it was right where one would expect to find the problem. nIndex was the issue.
Sorry about the post.
|
|
|
|
|
Hi guys, somebody can tell me how con i show a list of network interface in my mfc application? jus tell me how con i find devices...
|
|
|
|
|
try to use winpcap, it is easy.
|
|
|
|
|
See if this article is of any help.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'm creating an MFC application.
I was provided by the manufacturer the following code in a .h file:
#ifdef DEFINE_GUID
// The GUID that is used to identify this device's interface
// {AF1B231E-1180-420b-8CB6-2ED2A53F9F92}
DEFINE_GUID(GUID_DEVINTERFACE_ALTGENERIC, 0xaf1b231e, 0x1180, 0x420b, 0x8c, 0xb6, 0x2e, 0xd2, 0xa5, 0x3f, 0x9f, 0x92);
#endif
I #include this .h file into my .cpp file.
This is the way I use it:
HDEVINFO hDeviceInfo;
hDeviceInfo = SetupDiGetClassDevs(
(LPGUID)&GUID_DEVINTERFACE_ALTGENERIC, NULL, NULL,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
I get the following errors:
alt.obj: error LNK2001: unresolved external symbol
_GUID_DEVINTERFACE_ALTGENERIC
c:\...exe: fatal error LNK1120: 1 unresolved externals.
Could someone tell me if I forgot to include a library or something....
Thanks.
Kitty5
|
|
|
|