|
how do u do so, i've looked at the classwizard for those control but there r only 3 message which is OUTOFMEMORY, RELEASEDCAPTURE and CUSTOMDRAW. Thanks
|
|
|
|
|
Go to classwizard.(press CTRL+W) Go to Member Variable tab.
In the Class name box, click the CYourclass .
In the Control IDs box, click IDC_YOURID .
In the Category box change Value and then enter name of your control and click ok.With that name you can use your controler.Understand?
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Hi !
I have the following question : I have 2 machines A and B in the same workgroup and I have a DCOM server at machine A . I'm logging at A and B with different passwords , the probelm is that CoCreateInstanceEx succeds at B but I cannot call any methods of the created DCOM object .(security error 0x80070005)
How could I configure the DCOM sever and Client to work?
I tried DCOMCNFG to allow Everyone to access and launch but it's still not working
Thanks
Jancsi
xxx
|
|
|
|
|
I use a component that returns errors using the ISupportErrorInfo. I create this component inside another component and I can not access the error Description using the code below:
CoInitialize(NULL);
if (FAILED(CoCreateInstance(CLSID_AppSrv, NULL, CLSCTX_ALL,
IID_IAppSrv, (void**)&pAppSrv)))
{
::SysFreeString(bstrInCall);
return;
}
hResult = pAppSrv->DispatchService3(bstrInCall , &vResponse);
if (hResult == S_OK)
*szXMLResponse = vResponse.bstrVal;
else
{
HRESULT hr=S_OK;
IErrorInfo *err;
BSTR str;
hr = GetErrorInfo(0, &err);
if (FAILED(hr))
{
*szXMLResponse = "<error>Unable To Retrieve Error Message";
return;
}
hr = err->GetDescription(&str);
if (SUCCEEDED(hr))
{
CString szTemp;
szTemp = "<error>003 <description>";
szTemp += str;
szTemp += "";
SysFreeString(str);
*szXMLResponse = szTemp;
}
err->Release();
}
Note that GetErrorInfo never fails but GetDescription always fails. Note that this happens when both the components are installed into 2 different packages in the COM+. Also the threading model of the component that produces the error is Apartment while the threading model of the component that fails to access the error is Neutral.
Spiros Prantalos
|
|
|
|
|
What do you do on server side?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
The STA component is a gate to some services. The Neutral component actually accesses these services. The peculiar case is that if I will take the neutral component outside the COM+ it will retrieve the error info raised by the first component
Spiros Prantalos
|
|
|
|
|
First, you should check for S_FALSE from your call to GetErrorInfo(). S_FALSE means that there was no error info to return.
Second, I don't know exactly what you want. Are you sure the server sets the error info?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Ok let me be more specific.
1. I am sure that the component sets the info in the IerrorInfo for 2 reasons:
a. I can receive them and display them from an ASP page
b. I can receive them and display them from the debug program of the second component
as long as the second component is not inserted in the COM+. In other words using
either the debug or the release version of the second component I can receive the
err->GetDescription(&str) never fails. On the contrary when the com is inserted
in the COM+ the same method fails. The error number that I receive in the HRESULT
id -2147417842 and unfortunately does not correspond to a common error code.
2. The whole idea is like this:
COM2<------>COM1<------>SERVICES
COM1 and COM2 live in different packages of the COM+. COM1 is the gate to some
services. COM2 and COM1 are both declared as server in the COM+. COM2's threading
model is Neutral while COM1's threading model is Apartment.
The weird phenomenon in that case is that everything fails only if they are both in the the COM+. Thank you for your time.
Spiros Prantalos
|
|
|
|
|
Hi,
I have a small problem, a question - don't know whether
possible or not.
I have an application (MFC) in VC++, i want to change the
execution of that application. I want that whenever my
Windows machine runs that appl, on start of the
application, I place a Long jump to a position from where
my actual code is executed. (I want a 16 byte empty space)
at the begining of the file (but some fixed sized code
can occur before that 16 byte)
Can nebody help
Sameer
|
|
|
|
|
Something like this:
int main(void)
{
goto end_nop_block;
__asm{
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
}
end_nop_block:
...
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanx but actually i'll tell you the whole story...
I have a pogram that takes offset as an input and write 16 bytes of data (character) to the .exe file (like we do in HexDump or neother thing).
So now i want that whenever i compile my .exe the 16 bytes are free at the same offset, so that i can write my own data there.
like if i define char array[16];
So i have to write on this 16 byte
Manually what i am doing is, i am assigning some value to this 16 byte initially and when the program is compiled, i open up my HEX editor and search for this string and write what i want to write.
So, did you understand what i mean, and is this possible
Thanx again
Sameer
|
|
|
|
|
Hi,
I'm using CArchive to copy the contents of one file into another.
How do i know that i reached the end of the file? that is archive??
cfile srcfile,destfile;
carchive arsrc(&srcfile...
carchive ardest(&destfile..
while (????)
{
arsrc >> str;
ardest << str;
}
what shld be in ????
thanks,
ravi.
|
|
|
|
|
try this:
<br />
CFile srcfile,destfile;<br />
CArchive arsrc(&srcfile...<br />
CArchive ardest(&destfile..<br />
unsigned long ulFileSize, ulFilePos; <br />
ulFileSize = srcfile.GetLength();<br />
char copy;<br />
<br />
ulFilePos = 0;<br />
while (ulFilePos != ulFileSize-1)<br />
{<br />
arsrc >> copy;<br />
ardest << copy;<br />
ulFilePos++;<br />
}<br />
|
|
|
|
|
but i don't know the length of copy.
it's not 1 byte at a byte.
I tried using this too..!
while (ulFilePos != ulFileSize-1)
{
arsrc >> copy;
ardest << copy;
ulFilePos += copy.GetLength();
}
but sometimes it doesn't return correct length when it reads spaces
or something else (all in binary format).
any other go??
|
|
|
|
|
Open the files for binary input and output.
Does it work then?
|
|
|
|
|
i tried using CFiles as well.
but when i use this file at a later stage, it retrieves using CArchive
and it gives a problem while reading.
It expects certain string but it archive << str; returns series of strings.
So, i thought of using CArchive initially only.
Any other go?
|
|
|
|
|
Hi
Currently i am programming a shell extension. Everything works nice, except a new dialog. I created a new dialog with the visual editor and used the class wizard to generate a new MFC class for the dialog. But when i try to show the dialog in the InvokeCommand() function with .DoModal() it isn't displayed! But the InvokeCommand() function works well! I replaced the dialog showing code with a message box and it is displayed correctly! But why doesn't the dialog work?
I used the standard call form to show the dialog:
CDisplayInfoDlg dlg;
dlg.DoModal();
but it doesn't work. Anyone knows a solution?
|
|
|
|
|
Does your shell extension contain CWinApp derived class?
|
|
|
|
|
The main class is
class CCryptoCtxApp : public CWinApp
but the class which should display the dialog is
<br />
class ATL_NO_VTABLE CCryptoShlExt : <br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<CCryptoShlExt, &CLSID_CryptoShlExt>,<br />
public IDispatchImpl<ICryptoShlExt, &IID_ICryptoShlExt, &LIBID_CRYPTOCTXLib>,<br />
public IShellExtInit,<br />
public IContextMenu<br />
|
|
|
|
|
And what is the return value from DoModal()? DoModal() usually fails, when it cannot locate resources for dialog.
|
|
|
|
|
DoModal() returns IDCANCEL.
|
|
|
|
|
Problem is, that MFC works well within MFC application. Your shell extension is running under explorer.exe and that's not MFC application. DoModal() function can fail for two reasons - cannot locate resources or it is not happy with your main window - explorer window. I had similar problem and I finished with writing my own DoModal() function. I can send it to you this evening, if you want. Try to debug DoModal(), to find out, where it fails.
|
|
|
|
|
No, i will not try to debug it anymore. I tried it about 2 hours. Enough now
Perhaps i create a new MFC DLL containing the dialog.... i need the MFC functions in my program. But you may send me your DoModal() version.
thanks for your help
-Dominik
|
|
|
|
|
This is my class, which should help you. It uses my CSeException class from this site. Note, you must pass handle of your main window to DoModal() function.
class CDominikDlg : public CDialog
{
// Construction
public:
CDominikDlg(DWORD dwID, CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDominikDlg)
//}}AFX_DATA
MSG m_msgCur;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDominikDlg)
public:
virtual int DoModal(HWND hWndParent);
virtual int RunModalLoop(DWORD dwFlags = 0);
virtual BOOL PumpMessage(void);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CFont m_font;
// Generated message map functions
//{{AFX_MSG(CDominikDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#define WM_KICKIDLE 0x036A // (params unused) causes idles to kick in
CDominikDlg::CDominikDlg(DWORD dwID,CWnd* pParent /*=NULL*/)
: CDialog(dwID, pParent)
{
//{{AFX_DATA_INIT(CDominikDlg)
//}}AFX_DATA_INIT
m_font.CreateFont(8, 6, 0, 0, FW_THIN, 0, 0, 0, DEFAULT_CHARSET,
OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, _T("Courier New"));
}
void CDominikDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDominikDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDominikDlg, CDialog)
//{{AFX_MSG_MAP(CDominikDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDominikDlg message handlers
int CDominikDlg::DoModal(HWND hWndParent)
{
// can be constructed with a resource template or InitModalIndirect
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
m_lpDialogTemplate != NULL);
// load resource as necessary
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
HGLOBAL hDialogTemplate = m_hDialogTemplate;
HINSTANCE hInst = g_hDll;
HINSTANCE hinTmp = afxCurrentInstanceHandle;
HINSTANCE hresTmp = afxCurrentResourceHandle;
afxCurrentResourceHandle = g_hDll;
afxCurrentInstanceHandle = g_hDll;
if (m_lpszTemplateName != NULL) {
HRSRC hResource = ::FindResourceEx(g_hDll,RT_DIALOG,m_lpszTemplateName,MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));
hDialogTemplate = LoadResource(hInst, hResource);
}
if (hDialogTemplate != NULL)
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
// return -1 in case of failure to load the dialog template resource
if (lpDialogTemplate == NULL)
return -1;
// disable parent (before creating dialog)
//HWND hWndParent = PreModal();
//AfxUnhookWindowCreate();
BOOL bEnableParent = FALSE;
if (hWndParent != NULL && ::IsWindowEnabled(hWndParent)) {
::EnableWindow(hWndParent, FALSE);
bEnableParent = TRUE;
}
try {
// create modeless dialog
//AfxHookWindowCreate(this);
if (CreateDlgIndirect(lpDialogTemplate,
CWnd::FromHandle(hWndParent), hInst)) {
if (m_nFlags & WF_CONTINUEMODAL) {
// enter modal loop
DWORD dwFlags = MLF_SHOWONIDLE;
if (GetStyle() & DS_NOIDLEMSG)
dwFlags |= MLF_NOIDLEMSG;
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
}
// hide the window before enabling the parent, etc.
if (m_hWnd != NULL)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
}
} catch(CSeException *e) {
DUMPEXCEPTION(e);
::SetLastError((unsigned long)NTE_FAIL);
e->Delete();
} catch (...) {
TRACE(_T("%s(%d): Unknown exception.\n"),__FILE__,__LINE__);
m_nModalResult = -1;
}
if (bEnableParent)
::EnableWindow(hWndParent, TRUE);
if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
::SetActiveWindow(hWndParent);
// destroy modal window
DestroyWindow();
PostModal();
// unlock/free resources as necessary
if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
UnlockResource(hDialogTemplate);
if (m_lpszTemplateName != NULL)
FreeResource(hDialogTemplate);
afxCurrentInstanceHandle = hinTmp;
afxCurrentResourceHandle = hresTmp;
return m_nModalResult;
}
int CDominikDlg::RunModalLoop(DWORD dwFlags)
{
ASSERT(::IsWindow(m_hWnd)); // window must be created
ASSERT(!(m_nFlags & WF_MODALLOOP)); // window must not already be in modal state
// for tracking the idle time state
BOOL bIdle = TRUE;
LONG lIdleCount = 0;
BOOL bShowIdle = (dwFlags & MLF_SHOWONIDLE) && !(GetStyle() & WS_VISIBLE);
HWND hWndParent = ::GetParent(m_hWnd);
m_nFlags |= (WF_MODALLOOP|WF_CONTINUEMODAL);
MSG* pMsg = &m_msgCur;
// acquire and dispatch messages until the modal state is done
for (;;) {
ASSERT(ContinueModal());
// phase1: check to see if we can do idle work
while (bIdle &&
!::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE)) {
ASSERT(ContinueModal());
// show the dialog when the message queue goes idle
if (bShowIdle) {
ShowWindow(SW_SHOWNORMAL);
UpdateWindow();
bShowIdle = FALSE;
}
// call OnIdle while in bIdle state
if (!(dwFlags & MLF_NOIDLEMSG) && hWndParent != NULL && lIdleCount == 0) {
// send WM_ENTERIDLE to the parent
::SendMessage(hWndParent, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)m_hWnd);
}
if ((dwFlags & MLF_NOKICKIDLE) ||
!SendMessage(WM_KICKIDLE, MSGF_DIALOGBOX, lIdleCount++)) {
// stop idle processing next time
bIdle = FALSE;
}
}
// phase2: pump messages while available
do {
ASSERT(ContinueModal());
// pump message, but quit on WM_QUIT
if (!PumpMessage()) {
AfxPostQuitMessage(0);
return -1;
}
// show the window when certain special messages rec'd
if (bShowIdle &&
(pMsg->message == 0x118 || pMsg->message == WM_SYSKEYDOWN)) {
ShowWindow(SW_SHOWNORMAL);
UpdateWindow();
bShowIdle = FALSE;
}
if (!ContinueModal())
goto ExitModal;
} while (::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE));
}
ExitModal:
m_nFlags &= ~(WF_MODALLOOP|WF_CONTINUEMODAL);
return m_nModalResult;
}
BOOL CDominikDlg::PumpMessage()
{
ASSERT_VALID(this);
if (!::GetMessage(&m_msgCur, NULL, NULL, NULL)) {
return FALSE;
}
// process this message
if (m_msgCur.message != WM_KICKIDLE && !PreTranslateMessage(&m_msgCur)) {
::TranslateMessage(&m_msgCur);
::DispatchMessage(&m_msgCur);
}
return TRUE;
}
|
|
|
|
|
Hi there ,
I have a class lets say CMyClass, it contains a member variable of type CArray of lets say int.
Now I have a public function of this Class GetValue(int nIndex) now this function returns the Reference of int which is actually a reference to a particular index of my CArray type member variable.
Now here is the problem .. My GetValue function performs some checks before returning the Refrence . now in case the checks fails I dont want to return the reference .. in that case WHAT DO I RETUNR FROM MY CODE.
does any body understand what I am trying to ask ?
Abhishek Narula
"Learn to appreciate others ... World would appreciate you"
|
|
|
|
|