|
I made a program that used the gethostbyname(hostname); function in MFC. it worked fine. now when i tried to do the same in a win32 project it is returning null. before this i added the header file "winsock2.h". which showed some errors as redefinition of this xxxxxxx . then i removed it and added the ws2_32.lib reference, after which, it showed no errors but at gethostbyname(hostname); function it returns NULL. have i done anything wrong ? the hostname string contains a genuine hostname. Please answer this
Kss
|
|
|
|
|
Try to find the error that occurred using WSAGetLastError .
Go through this[^] to find out what happened.
Nibu thomas
Software Developer
|
|
|
|
|
Thank you, it helped me ,it was a silly error i didnot call WSAStartup() :->
thanks again
kss
|
|
|
|
|
Imediatly after filling a listview with all my data I wish to set the first item as selected.
I use the folowwing:
ListView_SetItemState(GetDlgItem(hwnd,ID_DATA_LIST),0,LVIS_SELECTED,LVIS_SELECTED);
ListView_SetItemState(GetDlgItem(hwnd,ID_DATA_LIST),0,LVIS_FOCUSED ,LVIS_FOCUSED);
This is setting the list item as selected, but it does not give it the focus. i.e. Selected items usualy are highlighted in blue, but mine are simply highlighted in grey until the item is clicked.
Is there something I am missing?
|
|
|
|
|
You should have to call the SetFocus function of the list view control.
nave
|
|
|
|
|
I understand that I need to use the SetFocus function, but where exactly should it be called?
WM_SETFOCUS // doesn't work
WM_INITIALIZE // doesn't work
When text is being updated within contols via WM_SETTEXT, would that cause a loss of focus? I thought these sort of procedures would pass the focus back if set at all.
|
|
|
|
|
u should have to set focus to the list control before you set an items selection state.
SetFoucs(GetDlgItem(hwnd,ID_DATA_LIST));
ListView_SetItemState(GetDlgItem(hwnd,ID_DATA_LIST),0,LVIS_SELECTED,LVIS_SELECTED);
nave
|
|
|
|
|
a) There is a style flag for listview that forces it to show selection in blue even when the control is out of focus
b) I guess you can call SetFocus(hwndOfYourListView) in WM_CREATE handler
WM_SETTEXT causes no loss of focus I believe.
|
|
|
|
|
waldermort wrote: I understand that I need to use the SetFocus function, but where exactly should it be called?
If it's a dialog then OnInitDialog
If it's a view then OnInitialUpdate
Nibu thomas
Software Developer
|
|
|
|
|
according to MSDN:
LVS_SHOWSELALWAYS
The selection, if any, is always shown, even if the control does not have the focus.
This is true but it isn't highlighted in blue. Nomatter where I place the SetFocus call, nothing is happening. I have tried before setting item state, after setting state, beginning and end of WM_INITDIALOG, WM_CREATE, WM_SETFOCUS, WM_IMNOTGIVINGYOUFOCUSHAHAHA. Infact the only place it is working is within WM_PAINT, but this is just wrong.
This control is on a dialog along with sevral other controls. The only other thing I can think of is to change the tab order, but still, SetFocus should be unrelated to the tabs.
|
|
|
|
|
Is this a dialog? If so then you must return FALSE from OnInitDialog if you are explicitly setting focus or else focus will be set to first control in the dialog.
Nibu thomas
Software Developer
|
|
|
|
|
Nibu, You're the best 
|
|
|
|
|
Try:
ListView_SetItemState(GetDlgItem(hwnd, ID_DATA_LIST), 0, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hehe, Thats what I would normaly do, but since it wasn't working as I wanted I decided to break it into two lines to attempt to determine what exactly was wrong :p
|
|
|
|
|
When you right click a CD/DVD-ROM, windows will show a menu, and one of its menuitem is just the "Eject"! I want to control the flow of eject action,when user click the menuitem, it will go into my codes.
I use the ModifyMenu function to modify the "eject" menuitem, but how could i know if the current menuitem is "eject",just as what i want? If use the MF_BYPOSITION flag, it is impossible to get the position of the "eject" menuitem. If use MF_COMMAND, after a long trace to code, i find the ID of "eject" menuitem can be case 31014://normal
case 30757://folder view
case 47://tree view while using folder mode
case 31078://short cut
case 102:// quick launch
case 38://tree view in the application of winrar
case 39://toolbar on taskbar
I have to use a switch statement to handle the condition.
I don't konw if the "eject" ID have other value, and if i find it, i have to modify my code, it boring me so much. Could someone help me to fix this trouble? All codes are place at function
HRESULT CXXXXXX::QueryContextMenu ( HMENU hmenu, UINT uMenuIndex,
UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags ).
Thanks!
|
|
|
|
|
Hello!
Could anybody, plz tell me the list of third party controls available, which can be used in an MFC Application.
Is there any third party control like XmlEditView?
Thanx a lot
"If you change then change for the good."
|
|
|
|
|
This is what I know:
UltimateToolbox Here[^]
UltimateGrid Here[^]
Nibu thomas
Software Developer
|
|
|
|
|
Hello!
Thanx for replying. But, i dun wanna this type of controls.
I want a control like XMLEdit view. It should be more or less like the document area of xml Editor.
Thanx
"If you change then change for the good."
|
|
|
|
|
|
I had an simple object by using ATL Object wizard and a generic class CTCPSocket.
The com object name is CTest and interface is ITest. This class had a interface Add and a connection point Fire_notify.
And CSocket had two methods add_in and notify.
The code as following:
//CTest class
CTest:Add(long port)
{
CTCPSocket sk;
sk.add_in(port);
}
CTest:OnNotify()
{
Fire_notify();
}
//CTCPSocket class
CTCPSocket:add_in(long port)
{
//create a socket and listening
}
CTCPSocket:notify()
{
//created a tcp connectiong?
//when created a socket accept,pass the event to CTest:OnNotify()
}
when the client call the CTest->Add method, CTCPSocket will create a socket and listening, but the problem is: when there is a tcp connection event,how to pass the event to CTest:OnNotify() from CTCPSocket:notify()?
Thanks
Brygid
www.ecq.name
|
|
|
|
|
Hi,
I want to concatenate a variable of type 'unsigned long' to a variable of type 'char []'. How can this be done, since strcat() function takes 'char' arguments?
Thanks.
-Kranti
|
|
|
|
|
This is how we do it:
<font color=blue>#include</font> <iostream>
<font color=blue>#include</font> <sstream>
<font color=blue>int</font> main( )
{
<font color=blue>using namespace</font> std;
<font color=blue>long</font> lng = 2000;
stringstream strs;
strs<<"hello: "<<lng;
cout<<strs.str();
}
Nibu thomas
Software Developer
|
|
|
|
|
You can use sprintf().
check here ... [^]
Vini
|
|
|
|
|
Assuming that you by char[] really mean std::string (because you're a conscious[1] developer that avoids bald arrays and pointers if possible, right? ), then do like this:
std::string ToString(unsigned long value)
{
char buffer[33];
return std::string(_ultoa(value, buffer, 10));
}
std::string concatenated(original.append(ToString(value)));
[1] Conscientious?
--
The Blog: Bits and Pieces
-- modified at 5:09 Monday 27th February, 2006
|
|
|
|
|
Johann Gerell wrote: Assuming that you by char[] really mean std::string
You assume too much. That wasn't what he asked at all.
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"
|
|
|
|