|
Actually, you are trying to find the location of your executable. (The project file is only present on your development system.)
Look at GetModuleFileName - it will tell you the full path name of your executable file - no matter where it is run from.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
but then i need a header winbase.h/windows.h and that's not included with my Express Edition.
So i was searching for a workaround?
|
|
|
|
|
I would find that hard to believe... if you don't have windows.h and winbase.h, you can't develop windows applications - even the express edition allows that. I know the express doesn't have MFC support, but then GetModuleFileName is a Windows API call.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
I did a search on my system and the files could not be found, strange? What do i need to have those files: Platform SDK?
I haven't created an executable yet for this small application but I can debug it! I'm going to try this today and see what happens with the application that i have so far.
Thanks for your time, I'm feeling like an idiot!
Regards
|
|
|
|
|
Yes, you need the Platform SDK. Once you install that, you should be in good shape.
Good luck.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
hello all,
i hav a question regarding PDF creation.There is a free activex control for PDF opration which comes along with acrobat reader.I want to know whether i can use this activeX to create a pdf.If we can then pls do tell the function names to be used for creating the pdf.Or Else any one please send me an free activeX control which can be used for creation as well as viewing of pdf.Sorry if i made the query look too big.
Thanks & Regards
|
|
|
|
|
Hi,
it depends of what the destiny computer has, if they have the AdobePDF phantom printer (automatically installed with adobe writer), you don't need anything but the usual printing and selection of that printer. If you want to ensure in any case the pdf... then you should comunicate with the ActiveX or another module able to do it, and send the contents of your document. Most probably is that you will need Threads.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hi gentlemen,
I am newbie to MFC programming and I have a problem creating a dialog on a separate thread from the main application.
My situation is: by clicking an icon on a toolbar, a dialog will be prompted and asking for input. As entered the numbers and clicked "OK", these parameters will be passed to the main application to run in a loop and the result will be displayed.
Without threading, the displayed result is obstructed by the dialog and applying the InValidateRect function is not satisfactory since the toolbar now becomes invisible.
Now I have create a "CSub" class based on CDialog and a "CDialogThread" class based on CWndThread. My question is, how to instruct the dialog to run on the thread, then how to pass the threaded dialog parameter back to the main application?
Thank you very much!
|
|
|
|
|
From what you explained I do not see any reason of introducing a new thread at least as far as the dialog concerns.
Without threading, the displayed result is obstructed by the dialog and applying the InValidateRect function is not satisfactory since the toolbar now becomes invisible.
This is not so clear. Why does the toolbar become invisible. What's the relationship between the dialog and InvalidateRect?
--
=====
Arman
|
|
|
|
|
Hi Arman, Thank you for your reply. The application is a MDI and the dialog is called by a function of the CView class. After the dialog passes the parameters to this function, it runs a loop which preforms a calculation and display results on the childframe window.
I tried to use InvalidateRect(NULL,NULL,true) inside the function before the loop but all the icons on the toolbar disappears and only reappears after the loop completes.
If use InvalidateRect(m_hWnd,NULL,true) then the dialog only vanish if I clicked "OK" while the dialog is upon the childframe window. If the dialog is partially away from the childframe window, then it remains appear despite I clicked "OK".
I was told that creating a separate processing thread for the dialog will solve the problem but I have little idea on multi threading with MFC.
Hope you understand and thank you very much!
|
|
|
|
|
Dear,
You need not take that much pain to accomplish this.
If all you need to inform is a count and some other simple parameters,
why dont you put them in the APP, and once you got the parameters from the dialog, AfxGetAPP(), update / set variables and then... your task is done...
regards,
haribabu
|
|
|
|
|
Hi, thank you very much. Do you mean the following?
(1)in APP.cpp
CDialog dialog
int t1 = dialog.parameter1
(2)in View.cpp
T1 = AfxgetApp()->t1
|
|
|
|
|
Ok, I'm new to doing this in C++, although I have done it in C#. As this code has to work inside another larger C++ project I have (game program) I can't just do it in C#.
In my click handler for a button I want to put text into a textbox control on my form. Unfortunately, the "text" is in a c-string (ie null terminated string), and so I'm not sure how to get it to work:
System::Void btnGen_Click(System::Object^ sender, System::EventArgs^ e)
{
BYTE bMacaddress[MAC_DIM];
CSoftwareKey::RetrieveMACAddress(bMacaddress);
char* pMacString = NULL;
CSoftwareKey::Buffer2HexString( bMacaddress, MAC_DIM, &pMacString );
tbMacAddress->Text = *pMacString; // <---- Problem line
}
I tried first making a string:
string strMacAddr(pMacString);
and then:
tbMacAddress->Text = pMacString;
but this doesn't work either (and I'm sure you are laughing now) =)
Anyway, how can I do this? Basically, pMacString points to something like this:
"000C41805D2D\0" ( if I am making sense )
and so that's what I want in the text box.
Thanks
Patrick
|
|
|
|
|
Mmmm,
are you asking to port from c# to c++? or c++ to c#?
Because... there are elements in your code that are unknown for me :S
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
No, the above code has nothing to do with C#, it is straight C++.
|
|
|
|
|
then I'm more newbie than I thought :P
hehehehe
I've never seen "^" used as "System::Object^ sender"
Nevermind,
your tbMacAddress->Text is a string or a char[x]?
I had some problems with CString and char* in VC++ because of the "\0" at the end of the CStrings. I solved it considering the CString as a vector and taking every letter in a loop and putting it in the place of the char[20] that was needed. Afterwards I passed the &char[0] where the LPCSTR was asked for and it worked. Finally I found another way to do it and changed it but... sometimes silly things give the way to the correct answer.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
|
My question has nothing to do with managed code.
Basically, forget the code which is confusing you, and just think of this as the question:
If you have a c-string (ie a null terminated string) and you want to set the Text in a textbox to that value, how do you do it?
For example, when a button on the form is pushed, set the textbox to the c-string's value.
Patrick
|
|
|
|
|
Hi,
to do that I associate a member variable (CString) to the CEditBox and when I push a button or happens whatever it shall happen, call UpdateData (FALSE);
On the other hand, as the CEdit is derived from CWnd. It should be possible to modify its text with SetWindowText( LPCTSTR lpszString ); but I'm not sure because I have never tried it, I do it as above (VC++ 6)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Code?
So if I tell you that you are given a variable:
myString[] = "0C34AZ"; // which is null terminated
what would be working code to put it in a textbox?
|
|
|
|
|
Hi another time,
ok, I have the DoDataExchange in my Form, and a member variable associated to my CEdit.
DDX_Text(pDX, IDC_MYEDIT, m_szMemberString);
I initialize it to “” (empty) in the constructor.
And then, in some events/messages I put the name of another element I saved in the Document, in the example a click in a ListCtrl (report mode) where my elements are listed
void CMyFormView::OnClickCtrlList(NMHDR* pNMHDR, LRESULT* pResult)
{ POSITION pos = m_clcMyList.GetFirstSelectedItemPosition();
if (!pos)
{ m_nRowNum = -1;
m_cbButton1.EnableWindow (FALSE);
m_ szMemberString = "";
UpdateData (FALSE);
}
while (pos)
{ m_nRowNum = m_clcRuleList.GetNextSelectedItem(pos);
M_szMemberString = pDoc->GetElementNameOfColumn (m_nRowNum);
m_cbButton1.EnableWindow (TRUE);
UpdateData (FALSE);
}
Invalidate (); UpdateWindow ();
*pResult = 0;
return;
}
Another way (without member variables and the DoDataExchange) can be:
void CMyFormView::OnClickCtrlList(NMHDR* pNMHDR, LRESULT* pResult)
{ POSITION pos = m_clcMyList.GetFirstSelectedItemPosition();
CEdit* pEdit = (CEdit*)GetDlgItem (IDC_MYEDIT);
if (!pos)
{ m_nRowNum = -1;
m_cbButton1.EnableWindow (FALSE);
pEdit->SetWindowText ("");
}
while (pos)
{ m_nRowNum = m_clcRuleList.GetNextSelectedItem(pos);
pEdit->SetWindowText (pDoc->GetElementNameOfColumn (m_nRowNum));
m_cbButton1.EnableWindow (TRUE);
}
Invalidate (); UpdateWindow ();
*pResult = 0;
return;
}
The function I’m using is: CString CMyDoc::GetElementNameOfColumn (int nRow);
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
I just realised why I'm having the problem I'm having.
I started a straight C++ project, and added a CLR form! I really didn't want a managed form, as I want to stick with unmanaged C++. duh
So, basically, either I do this in C# ( or managed C++ ) or I have to learn how to do windows forms
I think I'll stick to a console app to do this simple job and avoid the whole dang problem.
Windows programming is just to much of a pain to learn.
|
|
|
|
|
Hehehehe,
This is the same my partner said. He try to piss me off with "look, in VB I can print with just 2 lines", because I'm having problems to personalize a PrintDialog, margins, Bitmaps...
Windows programming is not easy at all. But it is not imposible, just a question of time and being persistent.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
If you want to set text for a control Textbox(editbox) or button you can use of SetWindowText();
|
|
|
|
|
Hi all,
I have created a dll file in VC++ 6 and use that dll file in VB.Net. But unfortunately, in VC++, I'm using some datatype that aren't supported in VB.Net. So i couldn't use that dll file.
Please show me what datatype i should use in VB.NET appropriate with following datatype in VC++ 6 :
BSTR -> what datatype in VB.NET i should use
LPCTSTR -> what datatype in VB.NET i should use
LPSTR -> what datatype in VB.NET i should use
unsigned int -> what datatype in VB.NET i should use
DWORD -> what datatype in VB.NET i should use
Please show me some guide. Any help will be welcome.
Best Regards
|
|
|
|