|
Thanks for your quick response
I have not done much but still you can check the code
This is the code from the dll Just have 3 function now
Install Uninstall and the global Keyboar procedure.
<br />
LRESULT CKeyHook::InstallKeyHook()<br />
{ <br />
g_hHook = ::SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, AfxGetInstanceHandle(), 0);<br />
return( KH_OK );<br />
}<br />
<br />
LRESULT CKeyHook::UninstallKeyHook()<br />
{<br />
::UnhookWindowsHookEx(g_hHook);<br />
return( KH_OK );<br />
}<br />
<br />
LRESULT CALLBACK KeyboardProc(INT nCode, WPARAM wParam, LPARAM lParam)<br />
{ <br />
switch (nCode)<br />
{<br />
case HC_ACTION:<br />
{<br />
return 1;<br />
}<br />
}<br />
return ::CallNextHookEx(g_hHook, nCode, wParam, lParam); <br />
}<br />
The test application just call InstallKeyHookin InitDialog
and UnInstallKeyHook in OnClose.
Regards
Anil
|
|
|
|
|
_anil_ wrote: g_hHook = ::SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, AfxGetInstanceHandle(), 0);
i think the problem is with the AfxGetInstanceHandle() used here. What i suggest is create a globel variable of HINSTANCE and set this parameter with the HINSTACE coming in the dll main. If ur using an MFC dll, set this variable as follows
BOOL CDllApp::InitInstance()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
hins=AfxGetInstanceHandle();
return CWinApp::InitInstance();
}
now pass this variable in the SetWindowsHookEx function
nave
|
|
|
|
|
Superb Its worked.
Now please tell me what is the difference beteewn the two?
Why did you think that that should be the error place.
Regards
Anil
|
|
|
|
|
sorry it wasn't the problem of taking the hinstance value in InitInstance. It was the problem of not calling AFX_MANAGE_STATE(AfxGetStaticModuleState());
i tried calling AfxGetInstanceHandle() from a dll as follow.
HINSTANCE h2 = AfxGetInstanceHandle();// Returns the instance of the exe
AFX_MANAGE_STATE(AfxGetStaticModuleState());
HINSTANCE h = AfxGetInstanceHandle();// Returns the instance of the dll
now i think u understood the problem.
nave
|
|
|
|
|
hi,
in an edit control if multiple characters are selected and user presses delete button how we can deleted text that is "selected text" in WM_KEYDOWN or
OnKeyDown handler??
same thing with OnChar also for backspace!!
Thanks and regards
Harshal
|
|
|
|
|
Call the CWnd::OnkeyDown() in the overrided Onkeydown()
Rinu Raj
|
|
|
|
|
hi rinu,
thanks for replying.
but what i want to do is something different
suppose "abcd" is the selected text and the caret is
positioned before 'a' and if someone presses delete
whole text will delete so i want to retrieve that text before it gets deleted.
means i want abcd to be stored in some buffer or CString variable
thank's
Harshal
|
|
|
|
|
You may check whether the DEL key is pressed in the OnKeydown() If it is pressed then store the edit box content in a string variable. After that call the CWnd::OnKeydown()
Rinu Raj
|
|
|
|
|
|
I have an MFC application (VS 2003 Std). There is a dialog window with CStaticText. For example:
CStatic lblRecno;
I want to change the colour of the CStaticText.
I am using the OnCtlColor function:
HBRUSH DlgBackup::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = NULL;
/*
if(pWnd->GetDlgCtrlID() == IDC_STATIC_LP)
or
*/
if( nCtlColor == CTLCOLOR_STATIC )
{
pDC->SetTextColor(clBlack);
pDC->SetBkMode(TRANSPARENT);
hbr = (HBRUSH) GetStockObject( NULL_BRUSH );
}
else
{
hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
return hbr;
}
To this place is OK.
Now I am changeing the lblRecno value in the while loop:
int lp = 0;
CString newTxt = "";
while(...)
{
++lp;
bewTxt.Format("%d", lp);
lblRecno.SetWindowText(newTxt);
}
But the new value lblRecno is displaying in the place of the previous value, an so on.
I think I should to use the WM_ERASEBKGND, but I don't know how to do it.
Can you help me.
Regards
mwgomez
Poland
|
|
|
|
|
What you want actually to show the static text one after another.
If you just place a while loop you can see that last value only.
Try with a timer updating the window text in regular intervals say 1 sec
Rinu Raj
|
|
|
|
|
No it doesn't work. Please try it.
I don't create CStatic it my sorce code, it is on the dialog window.
I am setting the new Value by lblRecno.SetWindowText(...)
I am setting the CStatic colour by OnCtlColor(...)
and the TIMER
void CDemoDlg::OnTimer(UINT nIDEvent)
{
lblLP.Invalidate();
CDialog::OnTimer(nIDEvent);
}
Regards
mwgomez
|
|
|
|
|
inside the timer do
void CDemoDlg::OnTimer(UINT nIDEvent)
{
static int lp = 0;
CString newTxt = "";
++lp;
newTxt.Format("%d", lp);
lblRecno.SetWindowText(newTxt);
}
then Start the timer in the initdialog
Rinu Raj
|
|
|
|
|
I think there is steel something wrong.
Please look at my source code. My dialog window is MOkno.h
public:
CStatic lblRecno; // for displaying recno
CButton btnStart; // button Start
int iLicznik; // increment variable
CString newTxt; // new value of the text = iLicznik as a Text
MOkno.cpp:
BOOL MOkno::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO:
SetTimer(ID_TIMER1, 1000, NULL); // my Timer is running every 1 s
return TRUE;
}
HBRUSH MOkno::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr;
if(nCtlColor == CTLCOLOR_STATIC )
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(clBlue);
hbr = (HBRUSH) GetStockObject( NULL_BRUSH );
}
else
{
hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
return hbr;
}
void MOkno::OnClose()
{
KillTimer(ID_TIMER1);
CDialog::OnClose();
}
On the dialog window tehre is a Start button. When user click on the button:
void MOkno::OnBnClickedButtonStart()
{
iLicznik = 0;
newTxt = "";
// suppose: It is a database, and I am reading records
// and display the current recno number
for(iLicznik = 1; iLicznik <= 1000; iLicznik++)
{
newTxt.Format("%d", iLicznik);
}
}
void MOkno::OnTimer(UINT nIDEvent)
{
CDialog::OnTimer(nIDEvent);
lblRecno.SetWindowText(newTxt);
}
Regards
mwgomez
|
|
|
|
|
There are some problems in your code
You may modify code like this
void MOkno::OnBnClickedButtonStart()
{
SetTimer( ...) // Set the timer here not in the oninitdialog
}
void MOkno::OnTimer(UINT nIDEvent)
{
static int i =0;
newTxt.Format( "%d", ++i );
lblRecno.SetWindowText(csTex);
CDialog::OnTimer(nIDEvent);
}
Rinu Raj
|
|
|
|
|
Thank you for yuour help, I must find the reason...
Regards
mwgomez
|
|
|
|
|
Your code is doing exactly what it is supposed to do. Paint-related messages are low priority so they do not get handled if other, high-priority messages are in the queue. This is why you do not see the lblRecno control being updated until the end. Lose the timer stuff and try:
void MOkno::OnBnClickedButtonStart()
{
for(int iLicznik = 1; iLicznik <= 1000; iLicznik++)
{
CString newTxt;
newTxt.Format("%d", iLicznik);
lblRecno.SetWindowText(newTxt);
}
} I just tried this (using 10000) and it worked fine.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
gomez_a wrote: But the new value lblRecno is displaying in the place of the previous value, an so on.
Of course. What are you expecting it to do?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i want to know about SQL Server and ODBC is someone who now something?
i want to make a conection with odbc (visualfoxpro database)!
please tell me a web adress where i can learn something !
thank you in advance !
Bravoone
|
|
|
|
|
Flaviu_2006 wrote: i want to make a conection with odbc (visualfoxpro database)!
Are you wanting a DSN or DSN-less connection? If the former, you'll first need to create a DSN using the ODBC Data Source applet.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Good Morning,
I have prob with pointer, in fact my principal class has a control activeX
witch i put it like variable m_DTC so it générate a class .cpp and .h
when I try to call it into a CDialog
i do like this :
in file .h Cmyinterface (class of control activeX) I put a pointer
Cmyinterface *pdc;
and in the main class in boutton evenement i write
CexempleCDialog exple;
exple.pdc=&m_DTC;
int nreponse =exple.DoModal();
if (nreponse)
{
return;
}
I have a bug
"Exception non generated in 0x7c2090db (mfc70d.dll) in project.exe:0xC0000005: Violation of access when reading from the location 0xcccccd1c.
when i add other CDialog calling the interface i have the same prob
I hope that i exposed well my problem.
|
|
|
|
|
zizzzz wrote: exple.pdc=&m_DTC;
Can you show how m_DTC is initialized ?
Have you stepped through OnInitdialog of CexempleCDialog ?
|
|
|
|
|
in main class
DDX_Control(pDX, IDC_ITDCINTERFACECTRL1, m_DTC);
and i just put:
cont.pDTC=&m_DTC;
in the CDialog CexempleDialog i call it directly
int rvalue=pDT->name_function();
How i must initialize it ?
zzzz, zizzz
|
|
|
|
|
The first thing to do when you get such a crash is to start your debugger. You will get a lot of information (where the crash occurs exactly, what are the values of the variables and pointers, ...). It could be helpfull to see where it crashes exactly. You could also use the callstack to check in which of your functions the problem occurs.
|
|
|
|
|
Hi to everyone.
I search the internet for my problem but nothing.
I use CDatabase and CRecordset to connect to MySQL server, without any problem.
The problem is that i can't see greek characters (i see only '?') from my application.
The records in MySQL stored correctly in greek and the connection string which i use is:
mysql.OpenEx("DRIVER=MySQL ODBC 3.51 Driver;SERVER=localhost;UID=root; PWD=123456;APP=Microsoft Data Access Components;WSID=localhost;DATABASE=mybase;CHARSET=greek;")
What is wrong?
Please help me!!!
Thanks a lot!!!
|
|
|
|