|
Dear all,
I have created a CListBox, with several lines of string, in a dialogbox.
How can I call another function automatically whenever the selection of string in the list box is changed (by the up and down arrow key)?
For example, in the function I want to get the text of the new position of the
cursor selection whenever the selection is changed etc..
Looking forward to your sincere reply! Thanks!
|
|
|
|
|
1- Add the OnSelchangeList() for selection handler
2- Get the index of the current selection like this:
int index = m_List.GetCurSel();
3- Do whatever you want with the index. One idea is to put a switch statement and call functions within.
Good Luck!
|
|
|
|
|
Hi,
let's say I have a 'CString ii("5 1 2 3 4 6")'. The first number '5' represents the quantity of numbers in the subsequent string; question is, after extracting the number '5' how do i then extract & put the rest of the numbers in say.. an array of int?? Tried using sscanf etc. with no luck. Help!!
Thanks in advance.
|
|
|
|
|
strtok or _tcstok depending on whether or not u are using unicode
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Hi,
I'm implementing a class that implements a Timer Pool,
my problem is that i don't want to use user timers, we do a lot of system
programming, but the Waitable Timers functions like CreateWaitableTimer
doesn't implement timeout values, have you already sometime implemented a
clean solution using this kind of timers with timeouts? Any
help will be appreciated,
thanks,
Joao Vaz
|
|
|
|
|
is WaitForSingleObjectEx() no use to you? It can wait for WaitableTimers
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
The timer itself doesn't implement timeouts because the function you use to wait for the timer does. WaitForSingleObject[Ex] and WaitForMultipleObject[Ex] do.
|
|
|
|
|
I am writing a property-sheet application (actually a dialog app with tabs - nothing to do with properties !). The property pages contain various controls including edit boxes. For some reason the property page receives a PSN_KILLACTIVE notification whenever the user makes a change in an edit control. This calls CPropertyPage::OnKillActive() which calls UpdateData().
This not only makes the tab look as if it has lost focus, it also completely messes up the range checking in DoDataExchange() - for example if the user deletes a character, or all the characters, in order to enter a new value, the value goes out of range and is trapped by DoDataExchange() before the user can enter the new value.
This doesn't appear to happen with other controls such as radio buttons.
Has anyone elese experienced this? Is it a bug? Is there a work-around?
Dave
Dave
|
|
|
|
|
I've noticed that sometimes when saving data to a (JET) database while using ADO, a query performed right after the changes may not contain the changes....in particular if you have more than a single connection object to the same database.
I've played with events to make sure that the data is actually commited to the database (the CommitTransComplete method is getting called), but haven't found any solution except to hard-code a wait which I suspect is a very very bad idea.
Anyone have any ideas or know have an idea what I'm fighting against??
Thanks!
Paul
|
|
|
|
|
my understanding is that changes are not broadcast across multiple connections as the potential traffic on the network (in a multiuser scenario) would be grim
the solution we came up with was either to build in an auto-refresh every minute or two, or to give the users a refresh button on the data entry screens
sql server works this way to in fact
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
The information seems to be available within a few seconds (somewhere between 2 and 4 seconds) so refreshing every minute wouldn't really help any....and I need the data within a second of having saved it to the database.
I don't want to hardcode a wait into the application, and the whole point of the current set of work that I'm doing is to optimize for speed....having just saved the user 10 seconds, I'd hate to have to give half of it away waiting for data.
I've come across a Q article which indicates that Jet has "lazy" writes and caches information within the connection. I've set a connection property that is suposed to make sure that transaction data is to be saved right to the file, but haven't found any way of making sure that the other connection's cache is refreshed. ;(
Paul
|
|
|
|
|
I had the same problem a couple of months ago with an Access 2000 database and ADO. The solution looks like the following:
pConnection->BeginTrans();
//modify data base in some method
pConnection->CommitTrans();
After CommitTrans() other connections will see the change that occurred between BeginTrans and CommitTrans. This will flush the result back to the database.
There is an article in the MSDN library that explains transactions in ADO. Search MSDN for "Using Transactions in Your Solutions" as an exact phrase. There should be one article, its in Visual Basic but the solution is similar in VC++.
John
|
|
|
|
|
Now I have a dual-monitor system. Is there any API function with which I can enable or disable the second monitor, but not by using control panel?
Thanks in advance!
Wang Huaizhi
|
|
|
|
|
Hi everyone,
My problem seems simple, but I don't know where to start. The problem is :
Having a process Id or Handle, how do you get the name of the process (whether the process is iexplore, netscape, or something else)?
Thanks for all your help
|
|
|
|
|
GetModuleFileName(processHandle,buffer,buffersize) (9x,NT)
or
GetModuleBaseName(processHandle,moduleHandle,buffer,buffersize) (NT4/5)
|
|
|
|
|
void CTestKeyDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
UpdateData(TRUE);
char lsChar;
lsChar = char(nChar);
if (lsChar == 83)
{
AfxMessageBox("This is SS!w");
}
else
{
MessageBox("This is not SS!");
}
UpdateData(FALSE);
}
Ok, this is the code i use to get a message box to tell me if the keyboard button was "S" or not.
It works fine, but only if the dialog is complety empty, no buttons nothing at all.
I cant get it to work, any one have a hint to what i have to do??
Thank you a million zillion times
|
|
|
|
|
in an empty dialog the dialog itself has focus as there are no controls ... appwizaed sets the focus to the first control after InitDialog() so KeyDn() at the dialog level gets the input ... when you have controls on the dialog they get the focus
the HookWindow() stuff should help or i'm sure there's a more 'correct' way out there
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Well i couldt find any info on the
HookWindow() in MSDN, any tips on how to use it.
The thing i need to do, is i need to get focus on the dialog, not the button's or text
is there a way i can get the message if the focus is on a Button??? Like it dosnt matter
if there is focus on the buttons or dialog??
Thank you again.
|
|
|
|
|
Try searching for HookWindow - I got eight matches, including two very useful articles, ( one of which is a Paul DeLascia one on palettes I refer to from time to time )
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Use PreTranslateMessage(). Like this:
in TestKeyDlg.h
class CTestKeyDlg : public CDialog {
....
bool PreTranslateMessage(MSG *pMsg);
....
};
in TestKeyDlg.cpp
bool CTestKeyDlg::PreTranslateMessage(MSG *pMsg) {
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 83)
MessageBox("That's S!");
return CDialog::PreTranslateMessage(pMsg);
}
With the best regards, Vitaly.
|
|
|
|
|
I get this error when i do the same as you do.
Error->(Sorry for the mess)
c:\documents and settings\administrator\my documents\c++\testkey\testkeydlg.h(16) : error C2555: 'CTestKeyDlg::PreTranslateMessage' : overriding virtual function differs from 'CDialog::PreTranslateMessage' only by return type or calling convention
d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
TestKeyDlg.cpp
c:\documents and settings\administrator\my documents\c++\testkey\testkeydlg.h(16) : error C2555: 'CTestKeyDlg::PreTranslateMessage' : overriding virtual function differs from 'CDialog::PreTranslateMessage' only by return type or calling convention
d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
C:\Documents and Settings\Administrator\My Documents\C++\TestKey\TestKeyDlg.cpp(128) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Generating Code...
Need a litle hint
|
|
|
|
|
I get this error when i do the same as you do.
Error->(Sorry for the mess)
c:\documents and settings\administrator\my documents\c++\testkey\testkeydlg.h(16) : error C2555: 'CTestKeyDlg::PreTranslateMessage' : overriding virtual function differs from 'CDialog::PreTranslateMessage' only by return type or calling convention
d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
TestKeyDlg.cpp
c:\documents and settings\administrator\my documents\c++\testkey\testkeydlg.h(16) : error C2555: 'CTestKeyDlg::PreTranslateMessage' : overriding virtual function differs from 'CDialog::PreTranslateMessage' only by return type or calling convention
d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2568) : see declaration of 'CDialog'
C:\Documents and Settings\Administrator\My Documents\C++\TestKey\TestKeyDlg.cpp(128) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Generating Code...
Need a litle hint
|
|
|
|
|
did u use class wizard to generate the correct handlers for the PreTranslateMessage() function?
otherwise you will in fact have different call sig / return value from the defined handler in the afxwin.h file
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Opss i was sleeping, i didnt get to much coffie in my cup
Thank you, and thank you all for helping me.
|
|
|
|
|
I would like to highlight any CWnd with a border like Spy++ does.
Now i just draw a rectangle but that overwrites any other window
that could be over the CWnd i would like to highlight. At it does
look very ugly afterwards.
But Spy++ manages to highlight windows without overwriting any
other windows that may cover. How does Spy++ do that?
|
|
|
|