|
actually, yes, it set the focus, but the problem is graphical (button style pb).
but i'd ask you one more thing : do you want to set the focus on the button, or change the default button ??
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You are correct, it does have focus, but does not accept the enter key.
I want to set the focus.
See the replys below
Many Thanks,
AORD
|
|
|
|
|
hum, it seems that what you need have been answered several ways, but at a low level...
did you try CWnd::GetDefID() ?
by using this function, the window the button is on will change its default button (it will remove the property from the last one to set it to the button you provide then). this way, you'll be able to press the "enter" key to use you button.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
AORD wrote: GetDlgItem(IDC_MY_BUTTON)->SetFocus();
Well, it wont work. I have been facing similar problems, and I go down to PostMessage() level. What you probably can do is, Get the handle of the button with which you would want to deal, and then continue by posting an appropriate message. The following code snippet should help solving your problem.
<br />
HWND hButton;<br />
GetDlgItem(ID_MYBUTTON, &hButton); <br />
::PostMessage(hButton, BN_SETFOCUS, 1, 0);<br />
Regards,
Rajesh R. Subramanian,
Cyberscape Multimeida Limited,
Bombay, India.
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
See my answers down ...
SkyWalker
-- modified at 11:46 Monday 14th November, 2005
|
|
|
|
|
toxcct is right.
The button gets actually the focus. You can prove that to yourself by pressing the "space" key after you set the control to that button. You will see how it goes down and up.
SkyWalker
|
|
|
|
|
... and to see the difference, add
PostMessage(WM_KEYDOWN, (WPARAM)VK_TAB);
in OnInitDialog()
This will start showing you the focus rectangle on your buttons.
SkyWalker
|
|
|
|
|
It is not during InitDialog(), It is that he wants the button to achieve focus during run time. The fact is that It acquires focus but still is not clearly visble. My solution works, I hope.
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
Rajesh R. Subramanian wrote: It is not during InitDialog(),
Correct. I want the user to press enter while the focus is on an CEdit control, then I want the focus to move to a CButton control. But the CButton control does not obtain its normal focus (as it would if the user had pressed the tab key).
Yes toxcct & Mircea you are correct, the CButton does obtain a sort of focus by using GetDlgItem(IDC_MY_BUTTON)->SetFocus(); and the button is drawn incorrectly and nothing happens when the enter key is pressed (the space key works).
::PostMessage(hButton, BN_SETFOCUS, 1, 0);<br /> This works the same as GetDlgItem(IDC_MY_BUTTON)->SetFocus(); .
PostMessage(WM_KEYDOWN, (WPARAM)VK_TAB);<br /> This strange because it moves the focus backwards, that is the focus does not follow the Layout Tab order, thats not expected. So I have changed the Tab order and now it works, but this is at odds with the tab order the user would expect
Thanks for the help , It's not quite right, but is close.
|
|
|
|
|
I wrote some useful code in my class
<br />
Class CMyListCtrl:public CListCtrl<br />
And now,I want to use these code in my new class CMyListView.
Originally,I want to inherit CMyListView from CMyListCtrl.
But I found that ListView do not inherit from ListCtrl.
So how can I use my own code for CMyListView with less modification!
Thanks a lot!
Don't look at me in that way!
|
|
|
|
|
CListView inherites from CCtrlView and eventually from CView in order to keep the documnet/view architecture whilst using a list view within your app....
in order to use your CMyListCtrl in a CListView i suggest embedding...i.e. embedd one in an other
class CMyListView : public CView
{
protected:
CMyListCtrl* m_pMyList;
}
hope this helps
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
you can use templates. See the source of CHTMLEditView and CHTMLEditCtrl.
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
-- modified at 1:24 Tuesday 15th November, 2005
|
|
|
|
|
I am not understanding what is the diff b/w LUID and SID
where SID is unique to every user and present in access token.
It can also be present in DACL to control access during a logon session.
what is the purpose of LUID.
Pls help me.Thanx in advance
-- modified at 2:43 Monday 14th November, 2005
|
|
|
|
|
what i read just now is LUID is a log on ID for a user(or its SID).Whether it means LUID changes every time the same user(SID)log in.Is there any other purpose of LUID
Pls help me.Thanx in advance
-- modified at 3:02 Monday 14th November, 2005
|
|
|
|
|
Hey can u tell me how to create a Modelless dialogbox
in an MFC application.
Till date i was creating a ressouce of dialogbox from
resource editor , then added a class for it and later
on use to display it by usin code.
CmyDialobox dlgbox;
blgbos.DoModel();
How do make it modelless dialogbox so the user can aslo
interact with the background MDI application.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
|
dlgbox->Create(ID,parent);
dlgbox->ShowWindow(style);
|
|
|
|
|
Small things are important
i have done this before but due to
imporper availibility of the docment
could not get to it back
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I have an object which will be used as a key in stl map. Although I had overridden all the comparison operator (==, >, <, >=, <=), the vc++ compiler still makes complain on:
Compiling...
point.cpp
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\functional(86) : error C2678: binary '<' : no operator defined which takes a left-hand operand of type 'const class Point' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\functional(86) : while compiling class-template member function 'bool __thiscall std::less<class point="">::operator ()(const class Point &,const class Point &) const'
Error executing cl.exe.
point.exe - 1 error(s), 0 warning(s)
Any suggestion/ advice is very much appreciated.
cheok
#include
#include <assert.h>
using namespace std;
class Point {
public:
Point() {
this->x = 0;
this->y = 0;
}
Point(int x, int y) {
this->x = x;
this->y = y;
}
Point(const Point &p) {
this->x = p.x;
this->y = p.y;
}
Point& operator=(const Point &p) {
this->x = p.x;
this->y = p.y;
return *this;
}
bool operator== (const Point &p) {
return (this->x == p.x && this->y == p.y);
}
bool operator> (const Point &p) {
// For simplicity, we ignore x.
//
return (this->y > p.y);
}
bool operator< (const Point &p) {
// For simplicity, we ignore x.
//
return (this->y < p.y);
}
bool operator<= (const Point &p) {
// For simplicity, we ignore x.
//
return (this->y <= p.y);
}
bool operator>= (const Point &p) {
// For simplicity, we ignore x.
//
return (this->y >= p.y);
}
private:
int x;
int y;
};
int main() {
map<point, point=""> m;
Point p1(100, 100);
Point p2(100, 100);
if(m.find(p1) == m.end()) {
m[p1] = p1;
}
// Although p1 and p2 are different objects,
// their content is the same through comparison on their
// private member variables x and y.
//
// Hence, p2 shouldn't be inserted into the map.
//
if(m.find(p2) == m.end()) {
m[p2] = p2;
assert(0);
}
return 1;
}
|
|
|
|
|
I think your definition of map m is incorrect for a start...
shouldnt it be :-
map < Point, Point > m;
?? - ie you havnt told the compiler what you're storing in map m. One thing you have done (great ) is define the < operator for your class .. from Cprogramming.com :-
"To use the map class, you will need to include and maps are part of the std namespace. Maps require two, and possibly three, types for the template:
std::map < key_type, data_type, [comparison_function] >
Notice that the comparison function is in brackets, indicating that it is optional so long as your key_type has the less-than operator, < , defined -- so you don't need to specify a comparision function for so-called primitive types such as int, char, or even for the string class. Moreover, if you overloaded the < operator for your own class, this won't be necessary.
The reason that the key type needs the less-than operator is that the keys will be stored in sorted order -- this means that if you want to retrieve every key, value pair stored in the map, you can retrieve them in the order of the keys. "
http://www.cprogramming.com/tutorial/stl/stlmap.html[^]
[Edit]
I think you also need to define the < operator with two operands thus :-
bool operator <(const Point &LHS, const Point &RHS){
return LHS.y < RHS.y;
}
[/Edit]
'g'
-- modified at 4:49 Monday 14th November, 2005
|
|
|
|
|
yccheok wrote: bool operator< (const Point &p) {
bool operator< (const Point &p) const
|
|
|
|
|
That's exactly solve my problem, thanks!
|
|
|
|
|
hi,
I am facing a problem in making arrow keys working for cpropertysheet in MFC in VC++ for help button only the tab key works there. what is the reason for arrow key being inactive. and how to resolve this problem???
Kartik
|
|
|
|
|
Is ur parent window is an activex control. If yes, then it will not work as expected. The problem is the ActiveX control doesn't own the message pump. The message pump is owned by the container application. Therefore, all the keystroke messages are taken by the container application and not dispatched to the modeless dialog box or propertysheet window.
Install a Windows WH_GETMESSAGE hook for the modeless dialog box/propertysheet derived class to allow it to intercept keystrokes and handle accelerators.
Bye
Cool Ju
|
|
|
|
|
hi ju,
my application is not an activeX control....
so how can i make the arrow key move on the help button...
thanks in advance....
|
|
|
|