|
Look up CreateProcess in MSDN. That is the call to use to launch another program.
|
|
|
|
|
Try ShellExecute then end the program. exit in a console app
good luck,
Bill
|
|
|
|
|
Thank you, both of you guys!
I tryed to read the MSDN just after I read your suggestions, but as I'm quite new on C++ it turned out to be too technical for my right now. The compiler didn't swallow my attempts that I tryed 5 minutes ago.
I found out that it is easier to learn something complete knew by studying existing examples. Is there any codesample out there which I can play around with?
Best regards, Peter
|
|
|
|
|
|
Dear Nishant S,
To avoid wasting bandwith on this excellent discussion forum, I've emailed you some further questions.
Regards,
Peter
|
|
|
|
|
Anonymous wrote:
To avoid wasting bandwith on this excellent discussion forum, I've emailed you some further questions.
Please post your questions in the forum, because then other people will also be able to help you. I usually don't answer to direct emails and often don't even read them. I already have a problem keeping my mail organized. And the big advantage of asking questions in the forums is that the answers will remain there for other people to see in future if they run into the same problems.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Okay, I'm trying to load the raw data of a resource of a custom type. I've named the type "JPG" and have created a resource with the ID "IDR_JPG1". The resource is located within the executable. The code that I've come up with is:
char* pData = 0;
HRSRC hRsrc;
HGLOBAL hGlobal;
DWORD dWord;
hRsrc = FindResource( NULL, ?, RT_RCDATA );
dWord = GetLastError(); // Produces 1813 (ERROR_RESOURCE_TYPE_NOT_FOUND)
hGlobal = LoadResource( NULL, hRsrc );
pData = (char*)LockResource( hGlobal );
I have no idea what I need to be putting in place of the question mark. The MSDN Library provides only unclear and essentially useless information. Also, I'm a little uneasy about locking up a resource and not releasing it. Do I need to release it? There is a FreeResource function but I'm told that it is depricated. I'd appreciate any info you could send my way.
|
|
|
|
|
Okay, to answer my own question . . .
hRsrc = FindResource( NULL, MAKEINTRESOURCE( IDR_JPG1 ), "JPG" );
Corrects the problem
|
|
|
|
|
Hello,
I am trying to force regedit to export a version 4 .REG file instead of version 5. This is an option in regedit, however I am using the command line
regedit /e filename destination to do my backup. I have searched msdn and other places looking for documentation on what arguments can be passed here to force a regedit 4 export, but have had no luck at all. Does anybody have any experience with this, or know where I can look for some documentation??
Thanks
Is it football season yet?
|
|
|
|
|
I've got an MDI MFC app.
(Irrelevant info in parentheses probably: I have a database class(built from ADO) )
An object 'db' is declared in view1. It opens a database which has to stay open while the program is running. Now I want to run one of the functions of db, in view2. View2 transmits a piece of information that is to be used in the argument list of the function. I need to use the same object, so I cant create a new one (cant open an already open database connection). What is the best mechanism to do this?
I was wondering about:
I only have two views and this tactic worked when I did a sendmessage from view2 to view1. But in the dropdown intellisense after doing pView-> I saw only the names of functions and didnt know if I could get to the db object as above.
Please let me know.
Thank you very much,
ns
The above snippet said that db was not a member of CView. I tried forcing it to be CTrain1View * (totally wrong I know) but was not acceptable to the compiler either.
Do I have to go via Doc variables and a sendMessage?
|
|
|
|
|
ns wrote:
An object 'db' is declared in view1. It opens a database which has to stay open while the program is running.
What stopped you from including 'db' in CYourDoc?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
It didnt want to do simple recordset functions like get record count etc. It bombed if I made it a doc object because the constructor creates all the objects like command and recordset etc. Thats why I put it in the View....
Thanks,
ns
|
|
|
|
|
in general, you should put all data and data manipulation functions in the doc and all data display functions in the view. the view should have very little to do with changing the data (except as is necessary to run the UI). anyway, that's the principle behind doc/view.
i usually send all data-changing UI events from the view to the doc, then let the doc call UpdateAllViews with enough information that the views can correctly show the data change. i rarely let the view actually change (and never store) the data directly.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
I really wanted to do that, but as I said in my prev email, simple functions like fields->recordcount etc (native ADO functions) were crashing. The same object instantiated in the view performed fine! I'll try again, but am not confident they will work in the doc...
Thanks for your input,
ns
Gave it one final try as a doc object.....I think it may work! Some functions are anyways. Thanks so very much for the pointers
ns
|
|
|
|
|
While I agree that the db member should be in the doc and not in the view, there's nothing programatically wrong with what you've been doing. IntelliSense cannot show you the members of CTrain1View since your pView is of type CView*, but casting it to CTrain1View* should work:
POSITION pos = pDoc->GetFirstViewPosition();
while (pos!= NULL)
{
CTrain1View* pView = (CTrain1View*)(pDoc->GetNextView(pos));
ASSERT_VALID(pView);
pView->db.MyFunc(arg from view2);
}
But of course, hard-coding a type cast like this is error prone. You could make it a little nicer by checking the type before the cast:
CView* pView = pDoc->GetNextView(pos);
ASSERT_VALID(pView);
if (pView->IsKindOf(CRUNTIME_CLASS(CTrain1View)))
((CTrain1View*)pView)->db.MyFunc(arg from view2);
Still, putting it in the doc is the right thing to do.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
when I run an MDI application and keep clicking down a non-client
area of a window, all other window look dead, which means they
don't draw anything on their client area. This is critical when
I develop a timer based application because all the timer message
are also blocked by keeping down my mouse cursor on a non-client
area of a window.
I want to avoid this. I want to make all windows run although I
keep clicking down the caption bar of a window.
Does anybody know a solution for this problem?
|
|
|
|
|
I am working on a multiple document MFC program and am having a little trouble getting the standard save dialog to work properly. This is the problematic code:
static char BASED_CODE szFilter[] = "Quizbowl Team (*.qbt)|*.qbt|All Files
(*.*)|*.*||";
CFileDialog m_File(TRUE, NULL, NULL, OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT, szFilter, this);
m_File.m_ofn.lpstrTitle = "Open Quizbowl Team";
if(m_File.DoModal() == IDOK)
{
...
((CMainFrame*)GetParent())->SwitchToForm(IDD_TEAMBLD_ROSTER);
...
}
What happens is that as soon as m_File.DoModal() is executed, all of the items in DoDataExchange no longer work. Any help would be appreciated.
|
|
|
|
|
bjenning wrote:
all of the items in DoDataExchange no longer work
Why? Did you call UpdateData(FALSE) somewhere in your program?
|
|
|
|
|
Nope, no UpdateData(FALSE) (no UpdateData(TRUE) in the problem function either). The problem that I am having is when it enters the next dialog. None of the sounds or pictures show up. This is also the case for each of the other dialogs in the project.
|
|
|
|
|
Maybe I'm just being stupid and missing something simple. Do you know of any good example code I could look at to make sure I'm using the CFileDialog class correctly? Thanks for your help.
|
|
|
|
|
Your code looks correct! That's why I guess your problem is somewhere else. I even use
same type of code in my script article.
void CScriptDemoDlg::OnBtnBrowse()
{
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
_T("Script Files (*.js; *.vbs)|*.js;*.vbs|Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"));
if (dlg.DoModal() == IDOK)
{
}
}
As my daughter would say, "... Whatever!"
|
|
|
|
|
I'm using CFormView in my program, and in one of my handlers, I open a new view and attempt to close the current. I call DestroyWindow() to kill the window. When I run it, the new form opens and the old one ends up behind it, but doesn't close. Everything inside the form turns to white, but the frame around it stays and can be repositioned as it normally does. It's as if the form itself has closed, but it has left the frame behind.
Has anyone seen this? I've also tried posting a WM_CLOSE message, but that does nothing at all. Can someone please help?
|
|
|
|
|
Are you destroying the view, or its frame?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
I guess it's the View. How can i destroy the Frame?
|
|
|
|
|
GetParentFrame()->DestroyWindow();
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|