|
Probably shouldn't have posted this as a reply to Richard... but you are correct.
|
|
|
|
|
They've written a book on even numbers now?
|
|
|
|
|
Use the modulus operator % to get the remainder
For instance: if (number % 2 == 0) then its even, and if (number % 2 != 0) then its odd.
Code to print only EVEN numbers..
#include <iostream>
using namespace std;
int main()
{
int num;
cout <<"Printing only EVEN numbers..\n\n ";
for(num = 1; num < 210;num++)
{
if ( num % 2 == 0 )
{
cout << num << " is even\t ";
}
}
cout <<"\n ";
return 0;
}
|
|
|
|
|
Or you could use the simple expression
int odd = num & 1;
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Is there any way to get Network Adapter Name, Link speed and network utilization like Task manager using native api?
|
|
|
|
|
Check out this page[^] in MSDN for information on the network APIs.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Now that's a page which is going to get a bookmark!
Cheers, AT
Cogito ergo sum
|
|
|
|
|
It's not always easy to find, but MSDN has the answer to a lot of questions.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I know, i'm a long term fan of the MSDN, the trouble usually is finding a good ref. and, once you found it to make sure you can find it again after a year or so. I recently lost a lot of usefull resources on a very nasty crash. Not happy
Cheers, AT
Cogito ergo sum
|
|
|
|
|
Addy Tas wrote: lost a lot of usefull resources on a very nasty crash.
Backup, backup, backup!
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Here I show how to use some of those functions that Richard referenced.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hi,
I need query to Weblogic & ISS server to monitor the peformance. I need to get average response time to execute queries. SO there are number of parametes to be monitored. Please guide to do so....
|
|
|
|
|
What does this question have to do with C/C++/MFC?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yes I want to do it with C++.
|
|
|
|
|
I think you need to do some research first and specify your requirements; perhaps starting here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
This is my first form in c++ win32, and I want to get the tab key rolling for testing my program code, so when I fill in the edit boxes, I can just tab to the text box.
I put this form in a mdi child window, and all the samples I found use a dialog box. GetDialogItem was quite popular.
With the create window, I added the WS_TABSTOP.
If I can figure out the message generated by having focus in the textbox, and pressing the tab key, I think I can get the message in the wndProc, and set the focus to the next textbox.
txt_Manage_CreateAccount_LastName_Field = CreateWindow(TEXT("edit"),
TEXT(""),
WS_TABSTOP | WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT,
winWidth - 205,
92,
180, 20,
hManage_CreateAccount,
(HMENU) IDC_MANAGE_CREATEACCOUNT_LASTNAME,
GetModuleHandle(NULL),
NULL
);
SendMessage(txt_Manage_CreateAccount_LastName_Field, WM_SETFONT, (WPARAM)hFont_txt, FALSE);
ShowWindow(txt_Manage_CreateAccount_LastName_Field, SW_SHOW);
|
|
|
|
|
jkirkerx wrote: ...so when I fill in the edit boxes, I can just tab to the text box.
What are you saying here? I consider edit boxes and text boxes to be one in the same.
jkirkerx wrote: If I can figure out the message generated by having focus in the textbox...
WM_SETFOCUS is sent to a window after it has gained the keyboard focus.
jkirkerx wrote: ...and set the focus to the next textbox.
Have you looked at GetNextDlgTabItem() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
DavidCrow wrote: What are you saying here? I consider edit boxes and text boxes to be one in the same.
I call them textboxes, was not sure of the exact nomenclature used by Pro's
DavidCrow wrote: Have you looked at GetNextDlgTabItem() ?
I did, but read too much into it indicating it would not work on a regular window, because the tab message would never be sent. It had to be a dialog box sending the message. I sort of tried it, but it was hard to test in the wndProc. If I put a F9 in the loop, I could not set the focus in the textbox and press tab key, because the loop kept stopping at the breakpoint.
Let me try it again.
|
|
|
|
|
I had to move a lot of dirt to get the lowdown on that advice, but overall in the end, it will work soon today
I Added the DS_CONTROL, and the WS_EX_CONTROL_PARENT, which is suppose to extend dialog messaging to my MDI Child Window, and added a method to see the message from the tab key, and a intercept.
I loaded this in my form load function. Can't get a handle back from GetNextTabItem, so I will go back and check my window settings.
I'm not sure if what I wrote is sane or not, but it's a start.
BOOL bReturn = FALSE;
while (GetMessage(&msg, NULL, 0, 0)) {
if (bReturn == -1) {
}
else {
TranslateMessage(&msg);
DispatchMessage(&msg);
WCHAR szMessage[50];
wsprintf(szMessage, L"msg=%u wparam=%u lparam=%u", msg.message, msg.wParam, msg.lParam);
SetWindowText(lbl_Manage_CreateAccount_Status, szMessage);
if (msg.message == WM_CHAR) {
if ( msg.wParam == 9) {
if ( msg.lParam == 983041 ) {
HWND nextTab;
nextTab = GetNextDlgTabItem(gManage, lbl_Manage_Label, FALSE);
DWORD errorCode = GetLastError();
SetFocus(nextTab);
}
}
}
}
}
|
|
|
|
|
|
I read the blog, good information, I just need to let it soak in for awhile.
I thinking that I need to abandon the whole gui part of my program and start again. Maybe I really blew it and should of used Dialog boxes for all my forms. Coming from Visual Basic, in that world, there pretty much all called forms, and you can assign a value to them to change the type they are.
I put this in my form load function of my MDI child Window, but I need to figure out what the message is when I press the tab key, and where to listen for that specific message so I can issue the go to next textbox. It's suppose to be some sort of message pre-processor, that will fork out the message to 2 different types of listeners.
BOOL bReturn = FALSE;
while (GetMessage(&msg, NULL, 0, 0)) {
if (bReturn == -1) {
}
else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
ReleaseDC(NULL, hdc);
|
|
|
|
|
Forget all this manually handling keys like you're doing below. Even if you succeeded you'll have all this messy code that's already built into the OS. Also, there's more to the dialog keyboard interface than tab, like the arrow keys. The answer is the IsDialogMessage function. Change you message pump so it looks something like this:
MSG m;
while(GetMessage(&m, NULL, 0, 0))
{
if (!IsDialogMessage(hManage_CreateAccount, &m))
{
TranslateMessage(&m);
DispatchMessage(&m);
}
}
Steve
|
|
|
|
|
I built on it even more today, and made it bigger, and thought I optimized it a bit more.
My thinking is saying only translate and dispatch DialogMessages?, and then run the rest of my code as is. Or wrap my new code in the if statement.
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
switch (msg.message) {
case WM_LBUTTONDOWN:
{
WCHAR *szTempData[150];
int iLength = SendMessageW(GetFocus(), WM_GETTEXT, (WPARAM)150, (LPARAM)szTempData );
if ( iLength > 0 ) {
SendMessage(GetFocus(), EM_SETSEL, 0, -1);
}
}
break;
case WM_CHAR:
short ks = GetKeyState(VK_SHIFT);
if (msg.wParam == VK_TAB) {
if (ks >= 0) {
SetFocus(GetNextDlgTabItem(hManage_CreateAccount, GetFocus(), FALSE));
}
else {
SetFocus(GetNextDlgTabItem(hManage_CreateAccount, GetFocus(), TRUE));
}
WCHAR *szTempData[150];
int iLength = SendMessageW(GetFocus(), WM_GETTEXT, (WPARAM)150, (LPARAM)szTempData );
if ( iLength > 0 )
SendMessage(GetFocus(), EM_SETSEL, 0, -1);
}
break;
}
}
|
|
|
|
|
Dump all the code above and replace it with mine.
Steve
|
|
|
|
|
So I spent a whole day writing all that for nothing?
Why does all the functionality that I wrote still works?
|
|
|
|
|