|
Sunayna wrote: the pop up menu created by default in the CEdit class?
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]
|
|
|
|
|
|
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]
|
|
|
|
|
Have you searched CP for "CEdit context menu"?
|
|
|
|
|
Sunayna wrote: How do I delete the pop up menu created by default in the CEdit class?
you have to derive the class from the CEdit and handle the WM_LBUTTONDOWN message and plant your new popup menu there!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
ThatsAlok andle the WM_LBUTTONDOWN message
Is it right??
Regards,
Sandip.
|
|
|
|
|
There is a MDIchild window which has the CEdit class. Initially page up and page down keys were working.On setting the virtual key codes for page up and page down, page up and page down is not working. How do I enable the functionality of Page up and page down
|
|
|
|
|
What is bad in handling the OnKeyDown/OnKeyUp and calling the scroll if pressed key is PageUp/Down??
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
There are two tabs in my application. One is the parent and the other is the child. The parent tab is CView and the child tab is the CEdit control. Page up and page down are working for the parent but not for the child. I tried to implement ur suggestion but still page up and page down isn't working for the child.
Thanks
|
|
|
|
|
Ok, in that case it is not going to work. I had the same problem and an easy solution I found (is not the best, I know it) was to declare Hot Keys with the VK_ that I wanted to check in other views. The Hot Keys are global in the app, but locally executed. For me worked. Take a look on that.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hi guys,
I am trying to implement some command-line arguments for my application. I would like to be able to run the program with "Program.exe -w800 -h600" to force the resolution to be displayed at 800*600.
I've come up with this basic code that I would have thought could achieve the goal I had in mind but I get the error
error C2446: '==' : no conversion from 'const char *' to 'int' There is no context in which this conversion is possible
So lpCmdLine is a pointer to a const char , so how do I extract the information I want from it? Wouldn't it have been easier for microsoft to just implement it as an array of char 's?
WINDOW_WIDTH and WINDOW_HEIGHT are both global integers.
for (int n=0; n < (sizeof(lpCmdLine) / sizeof(char)); n++)
{
if(lpCmdLine[n] == "-" && lpCmdLine[n+1] == "w")
{
char w[4];
w[0] = lpCmdLine[n+2];
w[1] = lpCmdLine[n+3];
w[2] = lpCmdLine[n+4];
w[3] = lpCmdLine[n+5];
WINDOW_WIDTH = w[];
}
if(lpCmdLine[n] == "-" && lpCmdLine[n+1] == "h")
{
char h[4];
h[0] = lpCmdLine[n+2];
h[1] = lpCmdLine[n+3];
h[2] = lpCmdLine[n+4];
h[3] = lpCmdLine[n+5];
WINDOW_HEIGHT = h[];
}
}
The solution probably has something to do with some hefty use of pointers
|
|
|
|
|
You should use atoi[^] if you want to convert a string (e.g. "800") into the corresponding integer.
|
|
|
|
|
sorry but I don't think that will work for my purposes
I need to be able to parse the string first for any - signs followed by either a w or h. Once I get that working then I would be able to use atoi to convert the numbers in the string but I can't get to that point using atoi
|
|
|
|
|
Your code has several flaws.
Try
int iLen = _tcslen(lpCmdLine);
for (int i = 0; i < iLen - 2; i++)
{
if ( lpCmdLine[i] == _T('-'))
{
if (lpCmdLine[i+1] == _T('h'))
{
WINDOW_HEIGHT = _tstoi(&(lpCmdLine[i+2]));
}
else if (lpCmdLine[i+1] == _T('w'))
{
WINDOW_WIDTH = _tstoi(&(lpCmdLine[i+2]));
}
}
}
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]
|
|
|
|
|
It took me a few minutes to understand your code (had to search through all the help files for all that stuff I've never seen before)
It looks like it should work.
But it doesnt
error C2664: 'wcslen' : cannot convert parameter 1 from 'LPSTR' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2664: '_wtoi' : cannot convert parameter 1 from 'CHAR *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2664: '_wtoi' : cannot convert parameter 1 from 'CHAR *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
And could you please give me some hints as to why my code is flawed? I was already aware there was something wrong with it, hence the reason it doesn't work.
|
|
|
|
|
OK. These errors arise because the LPSTR nature of lpCmdLine . Use:
int iLen = strlen(lpCmdLine);
for (int i = 0; i < iLen - 2; i++)
{
if ( lpCmdLine[i] == '-')
{
if (lpCmdLine[i+1] == 'h')
{
WINDOW_HEIGHT = atoi(&(lpCmdLine[i+2]));
}
else if (lpCmdLine[i+1] =='w')
{
WINDOW_WIDTH = atoi(&(lpCmdLine[i+2]));
}
}
}
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]
|
|
|
|
|
thankyou, your code works flawlessly.
Bloody legend :P
Now, may we discuss the bad things I did in my original snippet so that I may learn from it in the future? That would be nice
|
|
|
|
|
Sauce! wrote: Now, may we discuss the bad things I did in my original snippet so that I may learn from it in the future? That would be nice
Your original code:
for (int n=0; n < (sizeof(lpCmdLine) / sizeof(char)); n++)
{
if(lpCmdLine[n] == "-" && lpCmdLine[n+1] == "w")
{
char w[4];
w[0] = lpCmdLine[n+2];
w[1] = lpCmdLine[n+3];
w[2] = lpCmdLine[n+4];
w[3] = lpCmdLine[n+5];
WINDOW_WIDTH = w[];
}
if(lpCmdLine[n] == "-" && lpCmdLine[n+1] == "h")
{
char h[4];
h[0] = lpCmdLine[n+2];
h[1] = lpCmdLine[n+3];
h[2] = lpCmdLine[n+4];
h[3] = lpCmdLine[n+5];
WINDOW_HEIGHT = h[];
}
}
1. sizeof(lpCmdLine) = sizeof(LPSTR) = 4 (on 32 bit systems). You should use strlen(lpCmdLine) instead.
2. Since the code inside the loop accesses lpCmdLine[n+5] , the loop itself cannot run on the whole lpCmdLine 's range available.
So the loop controlling condition should be (n < strlen(lpCmdLine) - 5) to
prevent buffer overrun.
3. You wrote your own version of atoi , but it is wrong: suppose pCmdLine[0] to pCmdLine[3] containing the right input for the number, the (brute force and simplified) code for a atoi-like function may be
int value = 0;
value = pCmdLine[0]-'0';
value *= 10;
value += pCmdLine[1]-'0';
value *= 10;
value += pCmdLine[2]-'0';
value *= 10;
value += pCmdLine[3]-'0';
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]
|
|
|
|
|
1) Huh, missed that one completely. Probably could have been avoided if I could find some better documentation on the exact data-type and format of lpCmdLine. Microsoft's documentation was pretty poor.
2) thanks, I was wondering why you subtracted 2 from iLen in your example. I thought to myself "yeah, it's technically correct, but you don't need to do it" (what a stupid thing to think!) I didn't even think about preventing buffer overrun.
3) I'm not sure what you're getting at here...
|
|
|
|
|
Sauce! wrote: 3) I'm not sure what you're getting at here...
Well, suppose:
lpCmdLine = "-w800";
this really means
lpCmdLine[0] = '-';
lpCmdLine[1] = 'w';
lpCmdLine[2] = '8';
lpCmdLine[3] = '0';
lpCmdLine[4] = '0';
Consider lpCmdLine[2] = '8' . Here lpCmdLine[2] is a char variable holding the ASCII value of the character '8' (that is 56 decimal). If you write
int iFirstDigit = lpCmdLine[2];
then you make a mistake, because iFirstDigit will contain 56 instead of 8 . On the other hand, writing
int iFirstDigit = lpCmdLine[2] - '0';
you get the expected value (in a rather portable way), since numbers are ordered in the ASCII encoding following their natural (ordinal!) sequence, hence
lpCmdLine[2] - '0' = 56 - 48 = 8 .
Now, suppose you make the same for the following digits, obtaining
iFirstDigit = 8;
iSecondDigit = 0;
iThirdDigit = 0;
to finally build the number you have to exploint the base 10 positional numbering system, i.e. poorly speaking:
int iNumber = iFrstDigit * 100 + iSecondDigit * 10 + iThirdDigit;
I made the above in a incremental way on previously posted code.
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]
|
|
|
|
|
You're so clever :]
Thankyou very much for your help. You've been quite informative
I've never fully understood converting from char 's to int 's, but you've cleared it all up for me
|
|
|
|
|
Sauce! wrote: You're so clever :]
Thank you.
Sauce! wrote: Thankyou very much for your help. You've been quite informative
I've never fully understood converting from char's to int's, but you've cleared it all up for me
You're welcome.
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]
|
|
|
|
|
Sauce! wrote: if(lpCmdLine[n] == "-" && lpCmdLine[n+1] == "w")
...
if(lpCmdLine[n] == "-" && lpCmdLine[n+1] == "h")
lpCmdLine[n] is a single character, yet you are comparing to an array of characters (even though there is only one character present). You should use single quotes instead, like:
if (lpCmdLine[n] == '-' && lpCmdLine[n+1] == 'w')
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How to verify that calling process has read access to the specified range of memory in vista. Earlier IsBadReadPtr and IsBadWritePtr could be used. But it is not suggestible by Microsoft. Can I know any other alternate method to verify that calling process has access to memory
Thanks,
Venkat
|
|
|
|
|
In almost all cases the professional thing to do is crash. Why are you so insistent on implementing what is almost certainly a bad idea? We’ve had this discussion before. If you can give a compelling reason why your application is an exception I’ll give you some pointers, but I’m reluctant to be a part of the spread of bad programming practices.
Steve
|
|
|
|