|
Yes. I need to change the index of item. The new index will be postion of column after drag drop.
Mike.
|
|
|
|
|
Check out CHeaderCtrl::SetItem() and HDI_ORDER
|
|
|
|
|
Hai!
Can you please give me a sample code which calculates HCF and LCM of two or more numbers without using inbuilt functions to calculate HCF & LCM.
If there are more than one methods to calculate HCF/LCM just tell the logic and if possible provide sample code for the best logic.
Thankyou!
modified on Monday, February 16, 2009 1:11 AM
|
|
|
|
|
|
I must be doing something really silly but I'm trying to get the time information when a key is hit down then released (WM_KEYUP). I'm writing a win32 application (doesn't anyone write these anymore?), but when I hit the key, I get a blank messagebox or squares. What am I doing wrong. Any good advice might win you a keg of cool beer or at least, a thanks.
case WM_KEYDOWN:
{
SYSTEMTIME st;
GetSystemTime(&st);
MessageBox(NULL,(LPCWSTR)L"Time is "+ st.wMilliseconds,(LPCWSTR)L"Keystroke Analysis",MB_OK);
}
break; //etc
|
|
|
|
|
You cannot add a WORD type to a constant string.
Use the Format method of the CString class to generate the Text for the MessageBox .
«_Superman_»
|
|
|
|
|
|
EvScott wrote: doesn't anyone write these anymore?
Yes.
case WM_KEYDOWN:
{
SYSTEMTIME st;
GetSystemTime(&st);
const int BUFSIZE = 0x100;
TCHAR msg[BUFSIZE];
HRESULT hr = StringCbPrintf(msg, sizeof(TCHAR) * BUFSIZE, _T("Time is %d"), st.wMilliseconds);
if (SUCCEEDED(hr)) MessageBox(NULL, msg, _T("Keystroke Analysis"),MB_OK);
}
break;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks,CPallini.I still get the same values when I include your example. However, when I run in debug mode and examine the values, I can see the SYSTEMTIME.wMilliSeconds. Just don't seem able to access it in a messagebox.
|
|
|
|
|
I made a test, my code works on my system.
Could you please post your updated code? Are you doing a UNICODE build?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks CPallini - Just don't seem to get a sensible output. I've omitted your code for reasons of clarity.
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
SYSTEMTIME st;
PAINTSTRUCT ps;
switch (message)
{
case WM_PAINT:
{
HDC hdc = BeginPaint(hWnd,&ps);
EndPaint(hWnd,&ps);
}
return(0);
break;
case WM_KEYDOWN:
{
SYSTEMTIME st;
GetSystemTime(&st);
//get duration in milliseconds
}
break;
case WM_TIMER:
{
}
break;
case WM_KEYUP:
{
SYSTEMTIME st;
GetSystemTime(&st);
//get duration in milliseconds
}
break;
case WM_DESTROY: // onload from memory
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
|
|
|
|
|
Are you doing a UNICODE build?
What is msg value at runtime, after the StringCbPrintf call (use the debugger to see)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thank you so much CPallini for you contribution. I made a small change to your original code by changing _T to L"" and it worked.
Below is your code that I made small changes to.
HRESULT hr = StringCbPrintf(msg, sizeof(TCHAR) * BUFSIZE, L"Time is %d", st.wMilliseconds);
So I suppose all that's left is to ship that crate of cool beer to ya as promised in my original post.
|
|
|
|
|
EvScott wrote: I made a small change to your original code by changing _T to L"" and it worked.
Uhm, soooooooooo strange!
EvScott wrote: So I suppose all that's left is to ship that crate of cool beer to ya as promised in my original post.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
My function that call UpdateLayeredWindow work well when I use Window DC.
But when I try to use new memory DC that is created with CreateCompatibleDC function and Window DC, UpdateLayeredWindow return error code 8.
This so strange. How should I use memory DC to draw over Window DC using UpdateLayeredWindow function ?
|
|
|
|
|
[code]
// ints.cpp
#include <iostream.h>
int main ()
{
int i = 0;
int j,totals,x;
double avg;
int k = 0;
int smallest = 0;
int largest = 0;
do
{
cout << "Enter a number (enter zero to exit): ";
cin >> j;
i = i + j;
k = k + 1;
if (j > largest) { largest = j; }
if (j < smallest) { smallest = j; }
while (j != 0);
if ((x > 0 ) && (x < 999999999999)
{
largest = x;
if (largest < x)
{ largest = largest; }
}
totals = k - 1;
avg = double(i) / (double(k) - 1);
cout << "\n\n\nThe number of numbers is " << totals << endl;
cout << "The average is " << avg << endl;
cout << "the largest number is " << largest << endl;
system("PAUSE");
return 0;
}
[/code]
basically i am in need of dire assistance i created this code, but i can not seem to get it to pick up the smallest inputted integer, so if someone could help me, i am a nub and would be most apprciated. thanks!
|
|
|
|
|
int smallest = 0;
if (j < smallest) { smallest = j; }
Have a look at those 2 lines, and think a little bit more about what is going on.
If you're not certain, just "run" your program on paper. (yeah, pen and paper).
This signature was proudly tested on animals.
|
|
|
|
|
[code]
// ints.cpp
#include <iostream.h>
int main ()
{
int i = 0;
int j,totals,x;
double avg;
int k = 0;
int largest = 1;
int smallest = 1;
int l;
do
{
cout << "Enter a number (enter zero to exit): ";
cin >> j;
i = i + j;
k = k + 1;
if (j > largest) {largest = j; }
if (j < largest) { smallest = j; }
}
while (j != 0);
totals = k - 1;
avg = double(i) / (double(k) - 1);
cout << "\n\n\nThe number of numbers is " << totals << endl;
cout << "The average is " << avg << endl;
cout << "the largest number is " << largest << endl;
cout << "The Smallest Number is " << smallest << endl;
cin.ignore(0);
system("PAUSE");
return 0;
}
[/code]
this is the code i currently have i wrote it out and thought i need j to be the standard input, then i would want if smallest is greater than j i would want the smallest to be j then if j was less then smallest i would want it to be replaced, i dont know if i explained that well but thats what i have so far...
|
|
|
|
|
You should really indent and beautify the code.
It make very easy for another person to look at.
This is not at all readable.
«_Superman_»
|
|
|
|
|
ok so i got it to this:
[code]
// ints.cpp
#include <iostream.h>
int main ()
{
int i = 0;
int j,totals,x;
double avg;
int k = 0;
int largest = 1;
int smallest = 99;
int l;
do
{
cout << "Enter a number (enter zero to exit): ";
cin >> j;
i = i + j;
k = k + 1;
if (j > largest) {largest = j; }
if (j < smallest) { smallest = j; }
}
while (j != 5);
totals = k - 1;
avg = double(i) / (double(k) - 1);
cout << "\n\n\nThe number of numbers is " << totals << endl;
cout << "The average is " << avg << endl;
cout << "the largest number is " << largest << endl;
cout << "The Smallest Number is " << smallest << endl;
cin.ignore(5);
system("PAUSE");
return 0;
}
[/code]
which works but the problem being i need to ignore a ZERO ( 0 ) instead of a 5 :-/ but whenever i put a 0 as the stopping then it doesnt work...
|
|
|
|
|
Did you mean it doesn't work if you put 0 in place of 5 here - while (j != 5); ?
«_Superman_»
|
|
|
|
|
exactly if i change
while (j != 0);
cin.ignore(0);
to
while (j != 5);
cin.ignore(5);
the program works, but problem being is i need the number to be 0 to end the program...
|
|
|
|
|
1/ Please use the code block formatting, and the preview button - you'll be amazed how much easier your code is to read.
2/ As suggested, run your program with a pen and paper. You'll be surprised how much it helps.
3/ I'll give you a big clue you're already been given.
int smallest = 0;
if (j < smallest) { smallest = j; }
3a/
Think about how many numbers are smaller than zero. Are the numbers you've entering small than zero?
Changing it to 1 only makes things better than one.
3b/ You'll have the same problem with largest, if you type in all negative numbers.
Enjoy,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Initialize smalltest to the largest 4 byte integer :
int smallest = 4294967295 ;
if (j
|
|
|
|
|
*I* know that... though I'd recommend using MAX_INT...
But I was trying to lead the obviously a homework question in the right direction.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|