|
Hi Eli,
I am very sorry, there is no information about how to set focus to dialog itself in the URL I provided . May you can try posting the same question again. I hope somebody will know answer and help you!!
Best Regards,
Suman
|
|
|
|
|
Try returning FALSE from your dialog's OnInitDialog() override.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: Try returning FALSE from your dialog's OnInitDialog() override.
Dear Mark,
I created test application and tried returning FALSE, but the focus is still in edit box.
There should be some way to do this.
Best Regards,
Suman
|
|
|
|
|
hmmm Yes I tested that and I couldn't get it to work. The dialog wants the keyboard focus on a
control no matter what.
Trying to remove the focus was fruitless as well. I tried both SetFocus() and WM_NEXTDLGCTL.
*trying some more stuff...*
This looks promising ...
add a ON_WM_SETFOCUS() entry to the dialog's message map
Add an empty OnSetFocus() handler method:
void CMYDlg::OnSetFocus(CWnd*)
{
}
At the end of the dialog's OnInitDialog() override (instead of returning TRUE), add:
SetFocus();
return FALSE;
See if that works for you...
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Mark,
Thanks, now there is no focus on controls in a dialog.
What is happening if you are not calling SetFocus() in OnInitDialog()?
I hope Eli can get the messages in dialog!
Best Regards,
Suman
|
|
|
|
|
rp_suman wrote: What is happening if you are not calling SetFocus() in OnInitDialog()?
According to the docs, the default handler for WM_SETFOCUS is the one that sets the focus
to the correct control (it tracks which control internally).
WM_SETFOCUS is a notification so there should be no huge harm in not passing it to the default
handler.
It will effect the user interface - you may want to set the focus to a specific control at
some point. Users expect dialogs to act a certain way. With this method, when the user switches
to another app and then switches back, the focus will be set to the dialog but the default control
for the dialog may/will be set as well. A solution should probably be a bit more robust and
track which control should have focus when nevessary.
My 2 cents,
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
You can only trace queued message in PreTranslateMessage.
Manish Rastogi
|
|
|
|
|
hi i have to show the battery condition in an LCD in my dialog. i am having an xml file that shows the batterycondition. but i dont know how to show this by an image. pls help me.
|
|
|
|
|
People haven't answered your question, because there's quite a few things you need to do (and research), and lots of information missing
1/ Reading the XML file, and getting the battery condition information
2/ Making a dialog?
3/ Is the condition simply 0-100%? If so, you can use a progress bar
4/ If its more complicated, and you need to display an LCD look, look at the static and miscelleneous controls section on codeproject
5/ Just guessing, but you'll also need to have some sort of timer to uppdate this information every (eg) minute.
As you see, many things to do, and we know almost nothing about where you are now, what skills you have etc.
Another reason noone's replied: "pls help me" is a rubbish subject. The fact that your posting means you want help. Trying including something useful in your subject.
If you have more specific questions, feel free to post them, and people will be more likely to answer. They're nice folk here!
Iain.
|
|
|
|
|
I want to add popupMenu in a TreeCtrl.
I add the OnContexMenu message to the TreeCtrl class(I drived it from CTreeCtrl of course).
But it refuse to work.
Why?
Thanks.
|
|
|
|
|
kcynic wrote: I add the OnContexMenu message to the TreeCtrl class
Did you also add a ON_WM_CONTEXTMENU() entry to the derived class' message map?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I've been using c++ for two weeks now and i've got a good grip on coding by myself but...
is it possible to call a function like this:
char* myFunc(char* input)
{
printf(input);
}
int main(void)
{
char* one = "hello ";
char* two = "world!";
myFunc(one+two);
}
this is of the top of my head but can i add two strings together for a function?
Even if there is away around this would be great.
Thanks
|
|
|
|
|
Roman957 wrote: but can i add two strings together for a function?
No. There's not a + operator that will concatenate two char strings.
You'd need to do that manually - here's one way:
int main(void)
{
char* one = "hello ";
char* two = "world!";
char buffer[16];
strcpy(buffer, one);
strcat(buffer, two);
myFunc(buffer);
}
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
It may count as advanced at this stage of learning (getting arrays and pointers in your head is very handy!), but there are classes that encapsulate strings, and you can then use +
eg:
std::string one = "hello";
std::string one = "world";
somefunc (one + two);
Also look at CString if you're using MFC.
Iain.
|
|
|
|
|
visual 2005 sp1
the code in debug mode
s is a SOCKET value and set in unblock mode
pbuff is a char * pointer
isize is a int value , is the buff size of pbuff , about 6440
int i=recv(s,pbuff, isize , 0);
if(i==SOCKET_ERROR) //<--here is right
{
iierror=WSAGetLastError( );
if(iierror!=WSAEWOULDBLOCK) // if it is not a block error
{
return -1;
}
else retur 0 ; // need block and recv again
}
//--------------------------------------------------------
the code can run no error in release mode , and if the client send data immediately ,
it is ok , but if data no coming ,
the iierror value is 2, not wsaewouldblock , why?
refer to MSDN, the SOCKET error return more than 10000 ,
and I suppos it is a error of win api parameters, but when the data arrive in no time ,
the function runs ok , that means all parameters is ok ,
who knows why? and how to do with it?
should I replace with if(iierror!=2 || iierror!=WSAEWOULDBLOCK) return -1;
Thank you
Hello,
pleasure to meet you.
|
|
|
|
|
And if in release mode
the WSAGetLastError( ) will return the right value of WSAEWOULDBLOCK
never return 2
the code runs well in release mode, but why return 2 in debug mode?
Hello,
pleasure to meet you.
|
|
|
|
|
That doesn't make sense (as you know).
How are you checking the WSAGetLastError() return value in release mode?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
How are you checking the WSAGetLastError() return value in release mode?
It is simple to use ::OutputDebugString( ) or use my only calss qtlog , to record it to disk file or just send it by outputdebugstring to any windows debuger , use visual studio debug ->attach process , I can catch it .
But I really want to know why return 2 ? It seems just a bug of winsock .
Hello,
pleasure to meet you.
|
|
|
|
|
danscort yu wrote: But I really want to know why return 2 ?
It shouldn't.
What does the code look like that creates the debug string?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
OK,
I think I got the reason
Because I reset socket receive buffer size in my program
and in debug mode , system will not alloc system buffer for the socket if no data arrive
so it may return value 2 means file not ready or exist
If the data already arrive , even one and only one byte , system will alloc the buffer size as I reset , and then it will go well
In release mode , buffer will immediately alloc after reset buffer size of socket , so it will go well.
I just think it is a bug fo winsock in reset buffer size .
Hello,
pleasure to meet you.
|
|
|
|
|
danscort yu wrote: I reset socket receive buffer size
How are you doing that? Using what function(s)?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
The function pointer tutorials have a good example of passing a global function pointer as an argument and it's laid out in the following manner:
int DoIt(float x, char y, char z)
{
return 0;
}
void PassPtr(int (*pt2Func)(float, char, char))
{
int result = (*pt2Func)(12, 'a', 'b');
}
void Pass_A_Function_Pointer()
{
PassPtr(&DoIt);
}
My scenario is a bit different though. It's something more like:
int Class::DoIt(float x, char y, char z)
{
return 0;
}
void PassPtr(int (*pt2Func)(float, char, char))
{
int result = (*pt2Func)(12, 'a', 'b');
}
If I do the same as in the first instance and call PassPtr(&DoIt), it won't compile, giving me the following error when declaring the function pointer:
error C2276: '&' : illegal operation on bound member function expression
If I change the call to PassPtr(&Class::DoIt), it won't compile, giving me the following error when trying to pass the function pointer:
error C2664: <snip> cannot convert parameter 1 from 'int (__thiscall Class::* )(float, char, char)' to 'int (__cdecl *)(float, char, char)'
Some names have been changed, but this is pretty much what's going wrong. Does anyone know how to solve this issue? It would seem like I need to declare just a global function instead of actually passing a class member function.
|
|
|
|
|
|
|
Nemanjas link shows why you can't call member functions like this.
If declaring the method static isn't what you need (maybe your DoIt() method needs to access
non-static members of the class, for instance), it IS possible to call a member function through
a pointer, but as with all non-static class members, an object of that class is required.
The syntax is a little crazy but it's consistent with function pointers...
int Class::DoIt(float x, char y, char z)
{
return 0;
}
...
typedef int (Class::*ClassDoItPtr)(float, char, char);
...
void PassPtr(ClassDoItPtr pt2Func)
{
Class classobject();
int result = (classobject.*pt2Func)(12, 'a', 'b');
}
Hopefully I got that right
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|