|
hello all
what code do i need to write in MFC in order to check if the user has clicked alt key on the key board and how can i implement Alt+F4 fuction when the user clickes alt button on the key board and button(with caption F4) which is on my dialog box which is created in an SDI application
my alt and F4 button on the dialogbox has the following code in the fuction
void MyDialog::OnButtonalt1()
{
flag=1;
if( ( (WM_KEYDOWN||WM_SYSKEYDOWN) && (0x8000 ==(0x8000 & GetKeyState(18)) ) ) )
{
MessageBox("in Alt");
}
/*if( (WM_KEYDOWN && !GetKeyState(18)) && caps)
{
Invalidate();
}
BYTE keyState[256];
GetKeyboardState((LPBYTE)&keyState);
if( (TRUE && !(keyState[115] & 1))||(!FALSE && (keyState[115] & 1)) )
{
// Simulate a key press
keybd_event( 38,0x45,KEYEVENTF_EXTENDEDKEY|0,0);
// Simulate a key release
keybd_event(38,0x45,KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP,0);
}
*/
}
void MyDialog::OnButtonF4()
{
int i = GetKeyState(115);
if(i)
{
MessageBox("In F4");
}
}
Request to all to continue this
|
|
|
|
|
Dear u have done it, but you can't call WM_KEYDOWN ||WM_SYSKEYDOWN from inside a command, i do believe that you have to overload it as a seperate function inside that dialog, try it and it will work... Enjoy. Rabih
|
|
|
|
|
override virtual BOOL PreTranslateMessage( MSG* pMsg )
BOOL CMyDialog::PreTranslateMessage( MSG* pMsg )
{
if(pMsg->message == WM_SYSKEYDOWN)
{
//Check for F4 && Do Something
}
return CDialog:: PreTranslateMessage(pMsg);
}
|
|
|
|
|
hi,
how to find the execution time(time taken to execute) of any program in vc++
please help me out.
|
|
|
|
|
Hi
Call GetTickCount when your application starts. Refer MSDN for GetTickCount. Call GetTickCount again when your application stops. Now substract the both to get the execution time.
This will work fine if your application dont continuously execute for more than 49 days. If so you will have to do some extra work.
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
thanks a lot for your suggestion.
but i want find the time exactly, so i need to find number exection cycle of the program. with this execution cycle i can find the time taken by the code.
so please can you help me out in find execution cycle any code.
Regards and Thanking you
sham
|
|
|
|
|
does anyone know how to create a polygon for a graphics program on visual studio, i'm having problem figuring out the algorith, i know that i'm suppose to use vectors but i'm kind of lost. plus i have to ask the user to input the points of the polygon, any ideas
glowskull
|
|
|
|
|
I work with a subclassed CListCtrl. Tooltips will be displayed on the individual subitems; it works as expected.
I want to display tooltips on the header items as well. OnToolHitTest receives control, it sets the parameters, but OnToolTipText does not receive the control at all.
OnToolTipText will be mapped by
ON_NOTIFY(TTN_NEEDTEXTA, 0, On_ToolTipTextA)
ON_NOTIFY(TTN_NEEDTEXTW, 0, On_ToolTipTextW)
This should work for the CHeaderCtrl as well, should not it?
Btw, if I set the text pointer in OnToolHitTest directly in TOOLINFO.lpszText, instead of setting LPSTR_TEXTCALLBACK, it won't be displayed either (though it won't be ignored either: if I set the address of a constant string, I get an error, when it will be tried to release).
I did read about TTF_IDISHWND, etc. and tried all possible combinations, to no awail.
What else do I have to consider?
|
|
|
|
|
How do I make dialog to behave in a way that, no matter where I am clicking on the screen, I am always clicking the dialog (which is invisiable)? My program is to draw directly on the screen.
|
|
|
|
|
It depends on how it needs to act. There is away to set the transparency of a window on 2000? and XP. That is you could create a dialog that is invisable yet lets you see the screen behind it and draw on that. Or you can override the WM_PAINT and WM_NCPAINT, then only draw where you want, instead of drawing the the background and all that.
(best to do full screen window then).
The dialog needs to be the active window no matter how you do it.
There is one other possibiliy: Read up on the TRACKMOUSEEVENT, since SetCapture will not do the trick. I've used it
You may need to use a normal window instead of a dialog, if I remember correctly, dialogs do not give you much control of how there background is drawn.
Well out of ideas! I hope they were not to bad.
Good Luck!
INTP
|
|
|
|
|
Use a regular window (not a dialog), and give it the WS_EX_TOPMOST and WS_EX_TRANSPARENT extended styles.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
im using visual studio 2003.net and am trying to convert integer numbers from 1-255 into its equivalent ascii character then display it in a textbox, i tried to immediately display a character but the ascii code is the one that gets displayed. right now, im doing it the hard way by comparing each integer value and then placing into a variable its corresponding ascii character. is there a simpler way to do this? please help...
my original program flow:
char dataBuffer[512];
- data goes inside dataBuffer
- i get parts of it by using the index
- i use ToString() method to convert it to string
- display them in a textbox
the problem with this is that let's say,
dataBuffer[0] = 'A';
textBox->Text = dataBuffer[0].ToString();
OUTPUT: "65";
- i'd like it to be "A" instead of "65"
right now, i made a function which converts whatever is inside dataBuffer[x] by comparing it with ascii codes and placing in another variable the equivalent character, then that's what i display in the textbox.
i'm looking for a way to make it shorter 'coz the code to convert it is already about 510 lines.
please, please, please...
|
|
|
|
|
I don't do .NET, but have you tried:
textBox->Text = dataBuffer[0];
According MSDN online the ToString() method is doing exactly what is suposed to be doing.
INTP
|
|
|
|
|
yep, i tried that but the damn textbox keep on complaining that it cant convert char to string thingy or something like that...
|
|
|
|
|
Well if you where using regular C++ and the operator= accepted a regular C string ('\0' terminated) you could do the following.
char szTemp[2];
szTemp[0] = dataBuffer[0];
szTemp[1] = '\0';
text = szTemp;
or possibly
text = String(szTemp);
I do not know if that helped, but there is a .NET forum at CP, where I assume the experts hangout. There are also .NET articles, may be one of them will show you a code example.
Well I am done guessing!
Simple things keep getting harder to do (blast it anyway)!
INTP
|
|
|
|
|
I don't have .NET install on my machine, so I just can guess this.
dataBuffer[0] = 'A';
textBox->Text = String(dataBuffer[0]);
If it still doesn't work, try this:
dataBuffer[0] = 'A';
textBox->Text = (char)dataBuffer[0];
I hope this help.
Cheers...
Samin Thomas
|
|
|
|
|
i just did what "john" suggested and just appended a '\0' at the end of the character array. it seems to work fine...thanx again...
|
|
|
|
|
im using visual studio 2003.net and am trying to convert integer numbers from 1-255 into its equivalent ascii character. right now, im doing it the hard way by comparing each integer value and then placing into a variable its corresponding ascii character. is there a simpler way to do this? please help...
|
|
|
|
|
I think that if you just static cast the int to a char it will work...
ex.
asciiletter = char(intnumber);
|
|
|
|
|
What is wrong with this code? I get math errors,does not exit on entering n, and cannot print output? How do I make the program a page so the option to print is given.
// RWA's and Charges
#include <iostream>
using std::cout;
using std::cin;
using namespace std;
//using::endl;
int main()
{
int choice, c;
float amount,total,fee;
char choice3 ='y';
while(choice3=='y'|| choice3=='Y')
{
cout << "\nChoose from options below.\n";
cout << "\nEnter 1 to calculate total RWA cost.\n";
cout << "\nEnter 2 to calculate RWA base estimate.\n";
cout << "\n\t\tEnter your choice, then press the enter key:";
cin >> choice;
if (choice == 1){
cout << "\nEnter RWA Base Estimate, then press the enter key:$";
cin >> amount;
fee = amount * 0.04;
cout << "4% Management Fee:$" << fee <<"\n";
total = amount + fee;
cout << "Total:$" << total <<"\n";
if (total >= 1 && total <= 2499 ||total >= 1 && total <= 2,499)
{
cout << "Overhead:$" << total*0.1 <<"\n";
cout << "Total Obligation:$" << total + (total * 0.1) <<"\n";
}
if (total >= 2500 && total <= 9999 ||total >= 2,500 && total <= 9,999 )
{
cout << "Overhead:$" << total*0.09 <<"\n";
cout << "Total Obligation:$" << total + (total * 0.09) <<"\n";
}
if (total >= 10000 && total <= 24999 ||total >= 10,000 && total <= 24,999)
{
cout << "Overhead:$" << total*0.08 <<"\n";
cout << "Total Obligation:$" << total + (total * 0.08) <<"\n";
}
if (total >= 25000 && total <= 49999 ||total >= 25,000 && total <= 49,999)
{
cout << "Overhead:$" << total*0.07 <<"\n";
cout << "Total Obligation:$" << total + (total * 0.07) <<"\n";
}
if (total >= 50000 && total <= 99999 ||total >= 50,000 && total <= 99,999 )
{
cout << "Overhead:$" << total*0.05 <<"\n";
cout << "Total Obligation:$" << total + (total * 0.05) <<"\n";
}
if (total >= 100000 && total <= 299999 ||total >= 100,000 && total <= 299,999)
{
cout << "Overhead:$" << total*0.03 <<"\n";
cout << "Total Obligation:$" << total + (total * 0.03) <<"\n";
}
if (total >= 300000 && total <= 999999 ||total >= 300,000 && total <= 999,999)
{
cout << "Overhead:$" << total*0.015 <<"\n";
cout << "Total Obligation:$" << total + (total * 0.015) <<"\n";
}
if (total >= 1000000 && total <= 2425000 ||total >= 1,000,000 && total <= 2,425,000)
{
cout << "Overhead:$" << total*0.005 <<"\n";
cout << "Total Obligation:$" << total + (total * 0.005) <<"\n";
}
}
if (choice == 2) {
cout << "\nEnter Total RWA Cost, then press the enter key:$";
cin >> amount;
fee = amount * 0.04;
cout << "4% Management Fee:$" << fee <<"\n";
total = amount - fee;
cout << "Total:$" << total <<"\n";
if (total >= 1 && total <= 2499 ||total >= 1 && total <= 2,499)
{
cout << "Overhead:$" << total*0.1 <<"\n";
cout << "Spendable Amount:$" << total - (total * 0.1) <<"\n";
}
if (total >= 2500 && total <= 9999 ||total >= 2,500 && total <= 9,999 )
{
cout << "Overhead:$" << total*0.09 <<"\n";
cout << "Spendable Amount:$" << total - (total * 0.09) <<"\n";
}
if (total >= 10000 && total <= 24999 ||total >= 10,000 && total <= 24,999 )
{
cout << "Overhead:$" << total*0.08 <<"\n";
cout << "Spendable Amount:$" << total - (total * 0.08) <<"\n";
}
if (total >= 25000 && total <= 49999 ||total >= 25,000 && total <= 49,999)
{
cout << "Overhead:$" << total*0.07 <<"\n";
cout << "Spendable Amount:$" << total - (total * 0.07) <<"\n";
}
if (total >= 50000 && total <= 99999 ||total >= 50,000 && total <= 99,999 )
{
cout << "Overhead:$" << total*0.05 <<"\n";
cout << "Spendable Amount:$" << total - (total * 0.05) <<"\n";
}
if (total >= 100000 && total <= 299999 ||total >= 100,000 && total <= 299,999)
{
cout << "Overhead:$" << total*0.03 <<"\n";
cout << "Spendable Amount:$" << total - (total * 0.03) <<"\n";
}
if (total >= 300000 && total <= 999999 ||total >= 300,000 && total <= 999,999 )
{
cout << "Overhead:$" << total*0.015 <<"\n";
cout << "Spendable Amount:$" << total - (total * 0.015) <<"\n";
}
if (total >= 1000000 && total <= 2425000 ||total >= 1,000,000 && total <= 2,425,000)
{
cout << "Overhead:$" << total*0.005 <<"\n";
cout << "Spendable Amount:$" << total - (total * 0.005) <<"\n";
}
}
cout <<"********************************************************************""\n";
cout <<"***** Rate Range Subtotal Max. Range *****""\n";
cout <<"***** .01 .1 $2,499 $250.00 $250.00 *****""\n";
cout <<"***** 0.09 $2,500 $9,999 $675.00 $675.00 *****""\n";
cout <<"***** 0.08 $10,000 $24,999 $800.00 $1,200.00 *****""\n";
cout <<"***** 0.07 $25,000 $49,999 $1,750.00 *****""\n";
cout <<"***** 0.05 $50,000 $99,999 $2,500.00 *****""\n";
cout <<"***** 0.03 $100,000 299,999 $6,000.00 *****""\n";
cout <<"***** 0.015 $300,000 $999,999 $10,500.00 *****""\n";
cout <<"***** 0.005 $1,000,000 $2,425,000 $7,125.00 *****""\n";
cout <<"********************************************************************""\n";
cout<<"Would You Like to Perform Another Calculation (Y/N)?";
cin>>choice3;
}
//return 0;
cin >> c;
|
|
|
|
|
When you are storing the number (e.g. cin >> amount) you must include cin.ignore(); to ignore the carriage return ("\n").
|
|
|
|
|
Hey again to all...
I have a code that creates a dialog box...
But this dialog box is useless cause it doesn't handle
none of its messages...
And when I call DefDlgProc there is an error when it tries to handle message #48 (I think) about a 1000 times.
here is my code:
#include <windows.h>
#include "resource.h"
bool g_run = true;
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
ShowWindow(hDlg,SW_SHOW);
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
g_run = false;
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
HWND hwnd = CreateDialog(hInstance, (LPCTSTR)IDD_DIALOG1, NULL ,(DLGPROC)About);
if (hwnd == NULL)
{
DWORD err = GetLastError();
}
while (g_run);
return 0;
};
|
|
|
|
|
Hey... dude...
You need to change your while (g_run); line
to this lines:
BOOL bRet;
MSG msg;
while ((g_run) && ( (bRet = GetMessage(&msg, NULL, 0, 0)) != 0 ))
{
if (bRet == -1 )
{
}
else if (!IsWindow(hwnd) || !IsDialogMessage(hwnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
I wonder why it works ????<br />
Really.. I don't know why it works... but it does
|
|
|
|
|
I tell why it works...
it didn't work because your dialog window didn't recieve the messages.
Now it works because your dialog now recieves the messages...
that is why we need to use TranslateMessage and DispatchMessage .
|
|
|
|
|
M$ has used a GUID in the path of some of their critical objects i.e.
C:\Documents and Settings\Owner\Local Settings\Application Data\Identities\{520682BF-0796-481Z-AZB4-4E13X899C96E}\Microsoft\Outlook\
So my question is very simple: Where do the embed this information so they may access the same?
I checked the registry and no joy, and I looked for fake dll's and no joy.
So I must assofme that it is encrypted data, yes?
I don't want their info I just wish to understand the issues and how they formulate a pointer to the stored data.
"Naked we come and bruised we go."
- James Douglas Morrison
Best Wishes,
ez_way
|
|
|
|
|