|
So the Menu resource resides in Dll and you call load menu in Dll exported function and you use VS 6.0.
in the exported DLL function, call in the beginning.
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
[AFX_MANAGE_STATE^]
|
|
|
|
|
Thanks for handling all my answers this morning
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks mark
|
|
|
|
|
Hi,
I m' trying to integrate one of my sub-module applictaion(SDI)
into my major module..In such a case i m' getting the following
build error:
CVTRES : fatal error CVT1100: duplicate resource -- type:DIALOG,
name:130, language:0x0409
.\Debug\FINEART_V1.res : fatal error LNK1123: failure during
conversion to COFF: file invalid or corrupt
Error executing link.exe.
Kindly suggest me y it happens wats' the way of solvin tis error..
Gita
|
|
|
|
|
You've got duplicate ids in your .rc file.
Steve
|
|
|
|
|
Ya steve,
i got it k an provided with new ids..
thank u..
Gita
|
|
|
|
|
Hi,
I developing an application which hooks a Common dialog. i used CDM_GETFILEPATH to get the full path from Save dialog. But when there is not file extension is specified with the file name, the CDM_GETFILEPATH return's the full file path without any file extension.i thought If an extension is not given with the file name the default extension is concated with the file name. But this is not happing and CDM_GETFILEPATH give like this "C:\MyFolder\new" and not full path "C:\MyFolder\new.txt". Why?? . And is there any way to get the default file extension from a Common Dilaog using any Mesages and if so Which is that message?.
thanks
Nitheesh
|
|
|
|
|
Nitheesh George wrote: thought If an extension is not given with the file name the default extension is concated with the file name
only if you set lpstrDefExt of OPENFILENAME to some value, if it is NULL common dialog won't add the default extension. you can also change the default extension using CDM_SETDEFEXT message.
|
|
|
|
|
Hi All,
Help me out, it’s very urgent. Do and Die condition.
How to Run UNIX based EXE [MKS] through Shell in VC++ application.
Intermediate Shell should not be seen (It can be hide); target application should rum through SHELL.
And Target Application status should be returned whether target application run or not.
Example:
Intermediate Shell- Target Application
SHELL.exe à Target.exe
If any error occurs while running Target Application, return that status to application.
I am doing through _spawnl() API.
Int lnSts =_spawnl(_P_NOWAIT,”SHELL_PATH.exe”,”SHELL_PATH.exe”,”-Lc Target.EXE”,NULL);
But in this case if my target application having any problem like Target EXE has Segmentation Error. _spawnl will not return Target Application Fail Error.
It return intermediate SHELL execution status.
Is there any VC++ API, which executes any process through shell and returns its status?
Please help us. Any suggestion most welcome.
|
|
|
|
|
ShellExecute[^] (different than unix shell) is probably better than _spawn
What are the arguments or parameters that "SHELL.exe" can have ? can you pass it an executable path (filename) ?
Could you auto-generate a shell script to run your "Target.exe" that can be automatically be called by one of the dot file (.cshrc .tcshrc .login, ... ) ?
Other than that, I'm afraid your on your own.
|
|
|
|
|
Hi All,
Help me out, it’s very urgent. Do and Die condition.
How to Run UNIX based EXE [MKS] through Shell in VC++ application.
Intermediate Shell should not be seen (It can be hide); target application should rum through SHELL.
And Target Application status should be returned whether target application run or not.
Example:
Intermediate Shell- Target Application
SHELL.exe à Target.exe
If any error occurs while running Target Application, return that status to application.
I am doing through _spawnl() API.
Int lnSts =_spawnl(_P_NOWAIT,”SHELL_PATH.exe”,”SHELL_PATH.exe”,”-Lc Target.EXE”,NULL);
But in this case if my target application having any problem like Target EXE has Segmentation Error. _spawnl will not return Target Application Fail Error.
It return intermediate SHELL execution status.
Is there any VC++ API, which executes any process through shell and returns its status?
Please help us. Any suggestion most welcome.
|
|
|
|
|
kulkarniquiet wrote:
Is there any VC++ API, which executes any process through shell and returns its status?
Have you see this?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for reply. I have already seen that.
|
|
|
|
|
So have you tried the suggestions?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes,but till now no output.
I am searching more on this.
Thinking on terms of http://en.wikipedia.org/wiki/Spawn_(operating_system)
I am also thinking for
1. Call GetLasterror if any error occurs.
2. Using child PID, we can get ThreadContext using SetThreadContext API.
3. In this way, we can get error that is occurred in child process using _spawnl.
Need to explore more this method.
Any suggetions?
|
|
|
|
|
kulkarniquiet wrote: Any suggetions?
Does SHELL_PATH.exe open a console window?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Using the resource editor, I set up a menu item to call a function in a message map in a CListView class, but the menu item is greyed out and does nothing when clicked at runtime. The menu item is enabled and I added an event handler. I'm using the document/view architecture, but want to use a CListView to display a list of class objects derived from CObject, not part of the document. As far as I can tell, the message maps are all appropriate, the function to create and display the listview looks ok and the project compiles, links and runs without errors, just the menu item does nothing when clicked and the listview isn't displayed. I'm a beginner with C++/MFC and there's probably something simple I'm overlooking. Anyone have any suggestions? I can include code, but not sure what code to send. Thanks.
|
|
|
|
|
I'm using Visual C++ 6.0 on windows XP. (I'm new to C++/MFC) I want to write code that uses a spin control to increment a floating point value by some delta. When I add a spin control to my dialog window, in the class wizard I get only two choices when the IDC_SPIN (name ID I gave the spin object) is selected in Class Wizard message map - either UDN_DELTAPOS as a message or NM_OUTOFMEMORY message. If I tell class wizard to implement a function with UDN_DELTAPOS message, I get the code generated by the wizard as:
void CEditsDlg::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
}
That code is called each time the mouse is pressed while on the arrow, but I can't tell whether the up arrow or the down arrow is pressed. So if I use that routine, I don't know whether to increment or decrement a value like I want to.
All I want to do is when someone puts the mouse on the up arrow of the spin control in the dialog window, I want to increment a value. And if they put the mouse on the down arrow of the spin control, it decrements the value. I don't see how to code this.
Thanks ahead of time.
|
|
|
|
|
Kwanalouie wrote: That code is called each time the mouse is pressed while on the arrow, but I can't tell whether the up arrow or the down arrow is pressed. So if I use that routine, I don't know whether to increment or decrement a value like I want to.
The iDelta member of the NMUPDOWN is a signed value - positive for the up, negative for the down.
|
|
|
|
|
From MSDN:
pNMHDR is a long pointer to an NMUPDOWN structure that contains information about the position change.
The iPos member of this structure contains the current position of the control. The iDelta member of the structure is a signed integer that contains the proposed change in position. If the user has clicked the up button, this is a positive value. If the user has clicked the down button, this is a negative value.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have written the below code in the InitInstance method of application class
I have overwridden the dailog behavior by removing ok and cancel button and also by overiding the deafult behavior of esc and return virtual key down messages.
Now the problem is that I want to have control such that the lines after
dlg.DoModal();</ are executed as they are the lines that kill the dialog. he basic requirement to to kill the dialog only when a particular exe is executed. I'm waiting for this process to complete but that line is after DoModal after which the control is not going.
if (!CreateProcess(NULL, <br />
theApp.m_lpCmdLine, <br />
NULL, <br />
NULL, <br />
FALSE, <br />
CREATE_NO_WINDOW, <br />
NULL, <br />
NULL, <br />
&si, <br />
&pi)) <br />
status = GetLastError();<br />
<br />
CProgressActivityDlg dlg;<br />
m_pMainWnd = &dlg;<br />
dlg.DoModal();<br />
<br />
MessageBox(NULL, _T("Before loop"), _T("Test"), MB_OK);<br />
WaitForSingleObject(pi.hProcess, INFINITE);<br />
MessageBox(NULL, _T("Out of loop"), _T("Test"), MB_OK);<br />
<br />
CloseHandle(pi.hProcess);<br />
CloseHandle(pi.hThread);<br />
PostMessageW(dlg.GetSafeHwnd(), WM_CLOSE ,0, 0);<br />
AfxGetMainWnd()->PostMessage(WM_CLOSE, 0, 0);<br />
return FALSE;
|
|
|
|
|
tom groezer wrote: I'm waiting for this process to complete but that line is after DoModal after which the control is not going.
This really isn't going to work as designed.
If you insist on using a modal dialog, you'd have to poll for completion
from within the dialog class...not a very good design.
As with any other lengthy process, you should be waiting for completion on another
thread so you don't block the UI thread. If you need the UI to be in a modal state
until completion, there's a variety of ways to design the code. A couple examples:
1) Wrap the waiting worker thread in a modal dialog class. When the thread completes,
it can notify the dialog (with a posted message) and the dialog can close itself.
2) Disable the UI so the user can't do anything during the process (if necessary),
create a modeless dialog, and fire off the worker thread. When the thread completes,
it can notify the UI thread, at which time the UI thread can destroy the modeless dialog
and re-enable the UI.
However you design it, the main point is - blocking the UI thread for any lengthy
process (anything over a few seconds - some would say even less) is bad design, so
lengthy processes should be done on threads separate from the UI thread.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Here's an example of method 1 in my previous post:
IDD_PROCESSWAITER DIALOGEX 0, 0, 193, 50
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
CAPTION "Waiting..."
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CTEXT "Waiting for process to complete...",IDC_STATIC,7,17,179,8
END
#pragma once
class CProcessWaiter : public CDialog
{
DECLARE_DYNAMIC(CProcessWaiter)
CString ProcessPathname;
static UINT __cdecl ProcessCreatorAndWaiterThread(LPVOID pParam);
public:
CProcessWaiter(CWnd* pParent = NULL);
virtual ~CProcessWaiter();
INT_PTR ExecuteProcessAndWait(LPCTSTR pathname);
enum { IDD = IDD_PROCESSWAITER };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
protected:
virtual BOOL OnInitDialog();
virtual void OnOK();
virtual void OnCancel();
afx_msg LRESULT OnThreadComplete(WPARAM wParam, LPARAM lParam);
};
#include "stdafx.h"
#include "ProcessWaiter.h"
#define WMX_THREADCOMPLETE (WM_APP + 42)
IMPLEMENT_DYNAMIC(CProcessWaiter, CDialog)
CProcessWaiter::CProcessWaiter(CWnd* pParent )
: CDialog(CProcessWaiter::IDD, pParent)
{
}
CProcessWaiter::~CProcessWaiter()
{
}
INT_PTR CProcessWaiter::ExecuteProcessAndWait(LPCTSTR pathname)
{
ProcessPathname = pathname;
return DoModal();
}
UINT __cdecl CProcessWaiter::ProcessCreatorAndWaiterThread(LPVOID pParam)
{
CProcessWaiter *pThis = (CProcessWaiter*) pParam;
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo;
memset(&StartupInfo, 0, sizeof(STARTUPINFO));
StartupInfo.cb = sizeof(STARTUPINFO);
if (0 != ::CreateProcess(pThis->ProcessPathname,
NULL,
NULL,
NULL,
FALSE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&StartupInfo,
&ProcessInfo
))
{
::WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
::CloseHandle(ProcessInfo.hProcess);
::CloseHandle(ProcessInfo.hThread);
}
pThis->PostMessage(WMX_THREADCOMPLETE);
return 0;
}
void CProcessWaiter::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CProcessWaiter, CDialog)
ON_MESSAGE(WMX_THREADCOMPLETE, &CProcessWaiter::OnThreadComplete)
END_MESSAGE_MAP()
BOOL CProcessWaiter::OnInitDialog()
{
CDialog::OnInitDialog();
AfxBeginThread(&CProcessWaiter::ProcessCreatorAndWaiterThread, this);
return TRUE;
}
void CProcessWaiter::OnOK()
{
}
void CProcessWaiter::OnCancel()
{
}
LRESULT CProcessWaiter::OnThreadComplete(WPARAM wParam, LPARAM lParam)
{
EndDialog(0);
return 0;
}
#include "stdafx.h"
#include "ProcessWaiter.h"
...
CProcessWaiter ProcessWaiter(this);
ProcessWaiter.ExecuteProcessAndWait(_T("C:\\Windows\\system32\\notepad.exe"));
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Nice example
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?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Is it ok to have something like below to be posted. I just wanted to know whether passing WM_CLOSE is good enough as EndDialog();
PostMessage((((CProgressActivityApp*)lpParam)->m_pMainWnd)->GetSafeHwnd(), WM_CLOSE, 0, 0);
|
|
|
|
|