|
That doesn't always work. In fact, neither does my original response.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
hi i have read a file and then based on the result i have to add items in list control. the contents in the file can be changed. hence i have to read the file everytime. i dont know how to add the items in list control
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
Adding items to a List Control is simple, see for instance [^].
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.
|
|
|
|
|
Hi,
I'm facing a problem which i don't know how to solve...
I created a dialog which contains several edit boxes.
When activating the dialog , the first edit box automatically receives the input focus.
My problem is that I need to receive the ON_WM_KEYDOWN in the parent dialog,
but since the focus is on the first edit box - I will never get it.
I tried to catch the ON_WM_KEYDOWN message in PreTranslateMsg , but
I'm facing the same problem.
Anyone???
With best regards,
Eli
|
|
|
|
|
If you want to monitor when the text in the edit box changes, you could do something with the EN_CHANGE notification which is sent when the text in an edit box changes..
If you want to monitor keyboard messages, then i'm not sure that the WM_KEYDOWN message is applicable to dialog boxes.. You could try creating a window using the CreateWindow() or CreateWindowEx API, then programatically creating the controls, and then testing for the WM_KEYDOWN message..
Hope this helps!
--PerspX
|
|
|
|
|
Hi PerspX ,
First,thanks for your quick reply.
What is the difference between creating the control during the design time
and during runtime(the control is being created in a different way???).
Anyway,My problem is not catching the messages in the control,
but catching the messages in the dialog...
Thanks again,
Eli
|
|
|
|
|
No i mean creating the window using the CreateWindow() or CreateWindowEx() API as opposed to creating a dialog window. Creating a window like this will create a "proper" window as opposed to a dialog window - take a look at this article for more information. I think - but im not sure - that some window messages dont get passed to dialog windows and i think WM_KEYDOWN is one of them.. I think I have tried that in the past to no avail.. So create the window "properly", then create the controls in it using CreateWindow() and CreateWindowEx(), and specifying the control classes (see this article on MSDN if you do not know these classes).
Hope this helps!
--PerspX
|
|
|
|
|
eli15021979 wrote: I need to receive the ON_WM_KEYDOWN in the parent dialog,
but since the focus is on the first edit box - I will never get it.
May this link help you setting focus to dialog
Best Regards,
Suman
|
|
|
|
|
Hi Suman,
Thanks for the link...
However,it doesn't say how to set the focus to the dialog itself,but only
to one of the controls in the dialog(or maybe I didn't saw it?)
Thanks again,
Eli
|
|
|
|
|
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.
|
|
|
|