|
vishalgpt wrote: please suggest some work-around in this condition.
Not all the CRT functions are available at driver level so you need to check the DDK documentation for compatible functions. Many of the DDK functions have the prefix Rtl and are described here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
hi,
i'm curious if it's possible to find out ControlID of component under which was mouse pressed... of course i'd like to find it inside mouse hook.
LRESULT CALLBACK WinHookRunner::OnMouseEvent(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HC_ACTION) {
MSLLHOOKSTRUCT* pData = (MSLLHOOKSTRUCT*)lParam;
if(wParam == WM_LBUTTONDOWN){
qDebug("MOUSE: "+QString::number(pData->pt.x).toAscii()+":"+QString::number(pData->pt.y).toAscii()+" :: "+ QString::number(pData->dwExtraInfo).toAscii());
}
}
return CallNextHookEx(m_hMouseHook, nCode, wParam, lParam);
|
|
|
|
|
The MSLLHOOKSTRUCT structure has pt member which indicates the point at which the mouse was clicked.
Use this in a call to the WindowFromPoint API to get the handle of the control.
Then use this handle in a call to the GetDlgCtrlID function.
|
|
|
|
|
thanks a lot... exactly what i need!
|
|
|
|
|
i'm trying to change the keyboard layout from my program. it loads the new keyboard but doesn't activates it to the new layout.
here's my code:
please help me. i've to submit it asap.
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <conio.h>
using namespace std;
class _KeyboardLayout
{
public:
HKL hBengali;
bool bBengali;
HKL hEnglish;
bool bEnglish;
_KeyboardLayout();
} ;
_KeyboardLayout::_KeyboardLayout()
{
bBengali=false;
bEnglish=false;
}
int main()
{
_KeyboardLayout KeyboardLayout;
TCHAR szKeyboard[KL_NAMELENGTH];
int nBuff=::GetKeyboardLayoutList(0, NULL);
int nKeyboard;
HKL * phkl;
if((phkl = new HKL[nBuff])==NULL)
{
cout<<"Out of Memory !";
return 1;
}
int x=::GetKeyboardLayoutList(nBuff,phkl);
for(nKeyboard=0; nKeyboard<nBuff; nKeyboard++)
{
::ActivateKeyboardLayout(phkl[nKeyboard], KLF_SETFORPROCESS);
GetKeyboardLayoutName(szKeyboard);
if(wcscmp(szKeyboard,_T("00000445"))==0)
{
KeyboardLayout.bBengali=true;
KeyboardLayout.hBengali=phkl[nKeyboard];
cout<<phkl[nKeyboard];
}
if(wcscmp(szKeyboard,_T("00000409"))==0)
{
KeyboardLayout.bEnglish=true;
KeyboardLayout.hEnglish=phkl[nKeyboard];
}
}
delete [] phkl;
if(!KeyboardLayout.bBengali)
cout<<"error in bengali layout";
if(!KeyboardLayout.bEnglish)
MessageBox(NULL,_T("English (USA) keyboard layout not installed"),_T("Warning"),MB_OK|MB_ICONEXCLAMATION);
else
{}
cout<<endl<<::LoadKeyboardLayoutW(_T("00000445"),KLF_ACTIVATE | KLF_SETFORPROCESS);
if(KeyboardLayout.bBengali)
{
cout<<endl<<::ActivateKeyboardLayout(HKL(HKL_PREV), KLF_REORDER);}
return 0;
}
|
|
|
|
|
Hi there,
I am using a CAxWindow to implement an IWebBrowser2 control on an ATL Dialog. What I want to do is to display a facebook like button on my dialog.
As this is done via an HTML link, I embed the Webbrowser control into my dialog:
CAxWindow ieWindow = GetDlgItem(IDC_BROWSER_CONTROL);
ieWindow.QueryControl( & m_WebBrowserPointer );
if (m_WebBrowserPointer)
{
VARIANT v;
VariantInit(&v);
std::wstring link = L"http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com&send=false&layout=button_count&width=320&show_faces=false&action=like&colorscheme=light&font&height=21";
HRESULT res = m_WebBrowserPointer->Navigate(CComBSTR(url.c_str()), &v, &v, &v, &v);
}
This works fine so far. The "like"-button appears in my dialog. The problem begins when I click on the button and am not logged in to facebook.
Then, a login dialog appears (a new IE window). When I enter my login data without checking "Keep me logged in", the browser window closes and another browser window with the same content as before appears and I must enter the login data again. This happens 4 times, then the box at "Keep me logged in" is checked automatically, and the login works and my "like"-button changes its look (greyed out).
The login also works properly if I check the mark by hand.
So the problem is: Why does the login dialog appear several times after I have logged in? When I open the link in a standard browser window, the first try works correctly.
Do I have to submit other parameters to the call of Navigate()?
I also tried Fiddler to determine differences between the HTTP requests, but I couldn't figure out the differences. There seems to be a .js-script which loads the page again.
Please tell me if you need any more information. Thanks for your help!
Regards,
Fabian
|
|
|
|
|
Are there any other possibilities to show a browser window in an ATL dialog?
|
|
|
|
|
I have a COM dll used by an other application (release) on Windows 7 64bit.
The Debug version of dll COM works fine.
But the release version causes crash.
When trying to get the origin of problem (with "try...catch" )I discovered that it seems to be in the instruction below :
m_pConnection->Open(bstrConnectionString, wstrSuperUserDB.c_str(), wstrSACUserPassword.c_str(), Internal::adConnectUnspecified);
where :
m_pConnection : Internal::_ConnectionPtr
bstrConnectionString : _bstr_t
wstrSuperUserDB, wstrSACUserPassword : std::wstring
please have you any idea about this ?
|
|
|
|
|
compile the release version with no optimisations, enable debug code in the compiler and linker, then debug it
|
|
|
|
|
sorry for the mistake
I mean that the dll installed with the Installer causes crash.
but the dll I just compile (debug or release version) works well.
I think the problem is at this level (i'm not sure):
m_pConnection->Open(bstrConnectionString, wstrSuperUserDB.c_str(), wstrSACUserPassword.c_str(), Internal::adConnectUnspecified);
(this is using a log file)
Is this related to the creation of version installer or something else ?!
|
|
|
|
|
What is the value of m_pConnection at this point? I would suggest you add some code to check that your variables contain correct values.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
sorry for the mistake
I mean that the dll installed with the Installer causes crash.
but the dll I just compile (debug or release version) works well.
I think the problem is at this level (i'm not sure):
m_pConnection->Open(bstrConnectionString, wstrSuperUserDB.c_str(), wstrSACUserPassword.c_str(), Internal::adConnectUnspecified);
(this is using a log file)
Is this related to the creation of version installer or something else ?!
|
|
|
|
|
is it crashing *inside* that call, is m_pConnection valid, are the strings valid? What is the behaviour?
COM is normally very good at letting you know, via error codes, what's wrong
The installer should create no differences
|
|
|
|
|
if we considerate that Installer not make difference , why crash only on version installer ?
How know what is wrong via error codes?
|
|
|
|
|
when you find the crash, the answer will probably present it
It sounds like you have a problem you'll have to debug - again, are the pointers valid, are the parameters valid?
Another option is attach to the running version, either in Visual Studio, or with WinDebug, but, again, compile without optimisations, and make sure you generate PDB files
|
|
|
|
|
sorry for the mistake
I mean that the dll installed with the Installer causes crash.
but the dll I just compile (debug or release version) works well.
I think the problem is at this level (i'm not sure):
m_pConnection->Open(bstrConnectionString, wstrSuperUserDB.c_str(), wstrSACUserPassword.c_str(), Internal::adConnectUnspecified);
(this is using a log file)
Is this related to the creation of version installer or something else ?!
|
|
|
|
|
I'm not sure if this is possible but I would like to run some code every time a print job is started by any Windows application. Is there a method of detecting that this has happened? Like a message or something similar?
|
|
|
|
|
 use JOB_INFO struct
The JOB_INFO structures contain a Status member and a pStatus member. Both members contain status information of a print job reported by the port monitor. These two members differ in that the Status member is a bit field of states that contains predetermined values, while the pStatus member is a pointer to a string that could contain just about anything.
BOOL GetJobs(HANDLE hPrinter,
JOB_INFO_2 **ppJobInfo,
int *pcJobs,
DWORD *pStatus)
{
DWORD cByteNeeded,
nReturned,
cByteUsed;
JOB_INFO_2 *pJobStorage = NULL;
PRINTER_INFO_2 *pPrinterInfo = NULL;
if (!GetPrinter(hPrinter, 2, NULL, 0, &cByteNeeded))
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return FALSE;
}
pPrinterInfo = (PRINTER_INFO_2 *)malloc(cByteNeeded);
if (!(pPrinterInfo))
return FALSE;
if (!GetPrinter(hPrinter,
2,
(LPSTR)pPrinterInfo,
cByteNeeded,
&cByteUsed))
{
free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
if (!EnumJobs(hPrinter,
0,
pPrinterInfo->cJobs,
2,
NULL,
0,
(LPDWORD)&cByteNeeded,
(LPDWORD)&nReturned))
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
}
pJobStorage = (JOB_INFO_2 *)malloc(cByteNeeded);
if (!pJobStorage)
{
free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
ZeroMemory(pJobStorage, cByteNeeded);
if (!EnumJobs(hPrinter,
0,
pPrinterInfo->cJobs,
2,
(LPBYTE)pJobStorage,
cByteNeeded,
(LPDWORD)&cByteUsed,
(LPDWORD)&nReturned))
{
free(pPrinterInfo);
free(pJobStorage);
pJobStorage = NULL;
pPrinterInfo = NULL;
return FALSE;
}
*pcJobs = nReturned;
*pStatus = pPrinterInfo->Status;
*ppJobInfo = pJobStorage;
free(pPrinterInfo);
return TRUE;
}
BOOL IsPrinterError(HANDLE hPrinter)
{
JOB_INFO_2 *pJobs;
int cJobs,
i;
DWORD dwPrinterStatus;
if (!GetJobs(hPrinter, &pJobs, &cJobs, &dwPrinterStatus))
return FALSE;
if (dwPrinterStatus &
(PRINTER_STATUS_ERROR |
PRINTER_STATUS_PAPER_JAM |
PRINTER_STATUS_PAPER_OUT |
PRINTER_STATUS_PAPER_PROBLEM |
PRINTER_STATUS_OUTPUT_BIN_FULL |
PRINTER_STATUS_NOT_AVAILABLE |
PRINTER_STATUS_NO_TONER |
PRINTER_STATUS_OUT_OF_MEMORY |
PRINTER_STATUS_OFFLINE |
PRINTER_STATUS_DOOR_OPEN))
{
free( pJobs );
return TRUE;
}
for (i=0; i < cJobs; i++)
{
if (pJobs[i].Status & JOB_STATUS_PRINTING)
{
if (pJobs[i].Status &
(JOB_STATUS_ERROR |
JOB_STATUS_OFFLINE |
JOB_STATUS_PAPEROUT |
JOB_STATUS_BLOCKED_DEVQ))
{
free( pJobs );
return TRUE;
}
}
}
free( pJobs );
return FALSE;
}
|
|
|
|
|
Thanks for this information.
After a bit more research I actually found a completely different method of doing this using the "FindFirstPrinterChangeNotification" function. You can register for an event whenever the job queue changes and then just use "WaitForSingleObject" in the usual way to wait for the event to be triggered. This works well and you can even use same function to register for events on other printer related status changes.
|
|
|
|
|
Hello,
I have an Win32 COM application with GUI written in C++ (MFC). This GUI invokes a ATL COM client/DLL that acts as a sink to a ATL COM server. Everything works well. So we have 3 components here- MFC GUI app, COM client/sink and COM event server.
Now, I need to replace this native MFC C++ GUI application with .NET application. So I imported the COM dll that acts as sink into my .NET application and all interfaces were available as expected. When I make a specific method call in this COM dll/object, this method establishes sink connection with COM server (using AtlAdvise) without any issues. However, when the COM server raises an event, the call reaches the sink, but it fails in InvokeFromFuncInfo (specifically it DispCallFunc fails) from ATLCOM.h giving Access Violation error (0xC0000005). So to represent this:
1. .NET GUI ---create instance--->>> COM DLL (SINK) ---establish connection --->>>> COM Event Server
2. COM Event Server ---raise event--->>>ATLCOM.h (in COM sink DLL) fails in DispCallFunc with Access Violation (0xC0000005).
The above flow works perfectly well with my MFC GUI.
Is there anything required for this connectionable object or sink that I may not be setting in my .NET appliaction? How can I at least delve deeper to see what is going on?
thanks!
Vikram
|
|
|
|
|
the obvious thing to check for is that the .net gui still has an instance of the originating com object ...
|
|
|
|
|
The sink callback happens inside the COM object. In other words, when sink establishes connection with connectionable object and then expects event from COM server, the execution control is still inside the COM sink. So the instance is alive while this happens.
Could there be anything on .NET security side that I might be missing?
|
|
|
|
|
|
Thanks a lot! The specific section you gave a link for does look like what I am trying to do. Thanks 
|
|
|
|
|
Good link...What I am trying to do is slightly different though. In the post, the event sink is the .NET application it self. In my case, the event sink is another COM object and this sink COM object is instantiated from .NET application.
|
|
|
|
|