|
I found an article in MSDN - in the "books" or "partial books", maybe?
In my application I have a combo-box which allows selection of recording Primary or Secondary or both (this explains the names used in the code below!)
In my main window procedure, I use simething like:
case WM_COMMAND:<br />
switch(wParam & 0xFFFF)
{<br />
case ID_ToolbarRecordCombo:<br />
if (HIWORD(wParam) == CBN_CLOSEUP)<br />
{<br />
iComboBoxSelection = SendMessage(hWndRecordCombo,<br />
CB_GETCURSEL, 0, 0);<br />
if (iComboBoxSelection == 0 && <br />
recordingSelection != RecordPrimary)<br />
{<br />
recordingSelection = RecordPrimary;<br />
break;<br />
}<br />
else if (iComboBoxSelection == 1 && <br />
recordingSelection != RecordSecondary)<br />
{<br />
recordingSelection = RecordSecondary;<br />
break;<br />
}<br />
else if (iComboBoxSelection == 2 && <br />
recordingSelection != RecordBoth)<br />
{<br />
recordingSelection = RecordBoth;<br />
break;<br />
}<br />
}<br />
else<br />
return(DefWindowProc(hwnd, message, wParam, lParam));
I hope this helps!
|
|
|
|
|
thanks for your replay Norman,
it helped me very much but it only replys if iComboBoxSelection is =0....
Is there something wrong with my inserttion where I use CB_INSERTSTRING followed by indexing ... or do I use the COMMAND: case wrong?
/Peter
LRESULT CALLBACK ToolboxProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
LRESULT iComboBoxSelection;
switch(Msg)
{
case WM_INITDIALOG:
/*Add all the options to the combo box*/
char Buffer[64];
strcpy(Buffer,"Von Mises Z1");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,0,(LPARAM)Buffer);
strcpy(Buffer,"Von Mises Z2");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,1,(LPARAM)Buffer);
strcpy(Buffer,"Principal Major Z1");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,2,(LPARAM)Buffer);
strcpy(Buffer,"Principal Major Z2");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,3,(LPARAM)Buffer);
strcpy(Buffer,"Principal Minor Z1");
SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_INSERTSTRING,4,(LPARAM)Buffer);
strcpy(Buffer,"Principal Minor Z2");
//GetCurSel();
//iComboBoxSelection=SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_SETCURSEL, 0, 0);
// SendDlgItemMessage(hWndDlg,IDC_COMBO1,ON_CBN_SELENDOK ,0,(LPARAM)Buffer);
//SendDlgItemMessage(hWndDlg,IDC_COMBO1,CB_GETCURSEL, 0, 0);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_COMBO1:
{
if (HIWORD(wParam) == CBN_CLOSEUP)
{
iComboBoxSelection = SendMessage(hWndDlg,
CB_GETCURSEL, 0, 0);
if (iComboBoxSelection == 2)
{
MessageBox(hWnd, "iComboBoxSelection == 2", "Error",
MB_OK | MB_ICONINFORMATION);
}
if (iComboBoxSelection == 1)MessageBox(hWnd, "iComboBoxSelection == 1", "Error",
MB_OK | MB_ICONINFORMATION);
if (iComboBoxSelection == 0)MessageBox(hWnd, "iComboBoxSelection == 0", "Error",
MB_OK | MB_ICONINFORMATION);
}
break;
}
}
break;
}
return FALSE;
}
|
|
|
|
|
I found the error , thanks for all your help guys,--
/Peter
|
|
|
|
|
I'm trying to access a SQL server 2000. I will be reading data as well as updating or deleting records.
What is better; ADO, ODBC, CRecordset/ CDatabase?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
If you like STL-style programming, take a look at DTL[^].
If not, just forget about it
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Tom Wright wrote:
What is better; ADO, ODBC, CRecordset/ CDatabase?
I believe that CRecordset and CDatabase use ODBC, so those options are not mutually exclusive.
In any case, "better" is a relative term that only the application itself and the environment can dictate. I personally have used ODBC for both Access and SQL and it performed fine. That might not be the case if it were a high-volume application (e.g., several thousand transactions per second), though.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
No this app will read in one record and delete it every 20 seconds.
Easier in terms of learning and implementing in my app.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi guys.
I'd like to know how to retrieve if an application
was started by a user or by the operating system...
How can implemente something such this?
Thanks a lot..
bye
Jenie_net
|
|
|
|
|
Jenie_net wrote:
I'd like to know how to retrieve if an application
was started by a user or by the operating system...
All applications are started by the OS. What exactly are you trying to differentiate between?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Sorry David..I wasn't clear in my question.
I need to know if the application was started by a user-task,such as double clik on icon,by command line,by run dialog...or was started automatically by the o.s. ,may be at start-up...such register key..may be later..planned operations,or however in another way...but automatically by the operating system...
Sorry for the english if something is incorrect...
however thanks a lot...
Jenie_net
|
|
|
|
|
I know of no way to get that level of granularity. See if the th32ParentProcessID member of PROCESSENTRY32 is of any use.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
Not sure if this is the right forum for this question but I didn't see a networking stuff forum...
Is there an api/method for getting the signal strength of a wireless connection (802.11b/g) programatically. Windows XP is able to display the wireless signal strength when you bring up the status dialog of a wireless network connection, I would like to do something similar in my app.
This will probably be impossible in Win2k and below since third party applications managed the wireless connections, but in windows XP it should be possible.
Does anyone have any ideas?
Thanks Tom.
|
|
|
|
|
Hi,
Here is my idea, If that wireless modem is connected to u r serial port, then u must issue some command to that port using FILE IO APIs,so that modem will respond to u r command.For command set u must refer that that modem specs.
If that is inbuilt modem then i hope there must some APIs,i am not sure about this case.
PSN
|
|
|
|
|
A wireless (802.11b/g) interface adapter would never be connected to a serial port because rs232 transfer is way too slow... Regardless of whether it is a PCMCIA, PCI or USB 802.11b/g adapter windows will display it as a Network Connection.
Win XP is able to monitor signal strength through its Network Connections sub system, this is something that Win2K and below could not do...
This is why I am wondering if there is any way to tap into this functionality programatically?
Thnx Tom.
|
|
|
|
|
Check out the Windows XP Device Driver Interface.
There should be stuff about how to Access a Wireless Network card's Hardware Interface something like a DeviceIoControl function.
http://www.microsoft.com/whdc/device/network/wireless/default.mspx[^]
This is the Link on Microsoft Driver Website if that Helps.
-Ve
-of All the things I lost, I miss my mind the most...
|
|
|
|
|
Looking for a few good tut's on making screensavers..found the old jonny castaway screensaver and would like to make one similar to it. Will be using microsoft visual studio 6, c++ or VB. Any help would be appreciated......Thanks
|
|
|
|
|
Here is one:
http://www.codeproject.com/cpp/smoovcpscreensaver.asp
Nigel Thompson created another but I was unable to find it.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello, I had posted a question yesterday with no responses.. I figured I would give it one more shot..
I found a article on another site that talked about my problem.. here is a little blurb from the article...
If the terminating socket has been closed, calling Flush on the CArchive will raise an exception (so will calling Close). In the previous case, before the exception is handled, CArchive goes out of scope and its destructor calls Close. Close throws another exception and all hell breaks loose. Never throw exceptions from destructors.
You will need nested try / catch blocks ... [Article^]
My problem with the exceptions is fixed but I still have a memory leak.. Any ideas why??
void CMainFrame::OnSend(CClientSocket *pSocket, CString strMsg)
{ if(*pSocket != INVALID_SOCKET)
{
try
{
sendObject(pSocket, strMsg);
}
catch (CException* pEx)
{
pEx->Delete();
}
}
}
BOOL CMainFrame::sendObject(CClientSocket *pSocket, CString strMsg)
{
BOOL bRet = TRUE;
CSocketFile sf(pSocket);
CArchive ar_send(&sf, CArchive::store);
try
{
ar_send << strMsg;
ar_send.Flush();
ar_send.Close();
sf.Close();
}
catch (CException* pEx)
{
bRet = FALSE;
pEx->Delete();
}
return bRet;
}
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Hello,
The exception thrown is probably allocated using new . Try calling <delete> on pEx and see if that solves anything...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Why do you mean by call on pEx? If it was allocated using new shouldn't the pEx->Delete() clean it up?
Thanks for the response,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Hello,
I see, I forgot to close a <code> tag... It should read: call delete on pEx. I've just read the documentation on CException and I read that you shouldn't call delete on the object...
You can use a memory leak detect[^] mechanism to detect the leak. There are several others here on CP
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Didn't help, it ASSERTS if you try to 'delete pEx' the ASSERT says to use pEx->Delete() and not the other... Anyway I have traced the problem down some what, the Flush() causes a exception and so does the Close().. I'm not sure how I can catch both exceptions.. I can see 2 exceptions in the debug window yet my trace shows that I am only catching one of the two.. When I put another try/catch around the Close I catch it yet an extra exception occurs (3), this is just odd.. And the memory leak is still there.. weird..
I tried using AfxIsValidAddress() for the CArchive and CSocketFile and this worked like a charm in Debug mode, Said that the address wasn't valid when the connection was lost, yet said it was valid when the connection was present.. but in Release mode it fails every time, connected or not.. ever had any experence in using AfxIsValidAddress?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I use AfxIsValidAddress a lot, but I never experianced any problems with it.
I see that you catch exceptions, but I don't see you use the exceptions. You only delete them. What is the exception trying to tell you?
Besides that, if you application won't run for a long time and the memory leak isn't too big, I wouldn't worry about it.
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Just to simplify the code i didn't show what i do with the exception, actually I do a ...
char szError[4096];
pEx->GetErrorMessage(szError, sizeof(szError));
TRACE("sendObject Error: %s\n", szError);
pEx->Delete();
... For testing I sometimes used a AfxMessageBox..
anyway, the memory leak is super small, and actually the application will never get that far unless the super un-natural happens, but it still bothers me that I can't figure it out so I just wanted to see if anyone had any ideas..
Thanks for all your help!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Hello All,
It is well know that other systems in my LAN can connect to my machine by typing "\\User\d$" at the Start Menu->RUN... command and entering the password.
Q) Is there any way i could get the list of machine(Ip or Name) connected to mine. Does the sytem registry keep track of all the machines which have/are connected.
please get me some code if possible.
Regards,
Prax
|
|
|
|
|