|
What is the difference between Tab Control and Property Sheet?Is there any advantages and dis between these two?
|
|
|
|
|
Humm, dont know the difficulties in Tab Control but i find propertysheet&page very easy to implement and manage.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
I have a MFC based dialog application which uses ShellExecute() to launch executables. After calling ShellExecute with for example:
ShellExecute( hwnd,"open",
"C:\\program files\\winamp\\winamp.exe" ,
"c:\\song.mp3",
"c:\\program files\\winamp\\",
SW_SHOWMINNOACTIVE );
I have tried SW_SHOWMINNOACTIVE and SW_MINIMIZE and after the call to launch the executable my dialog application loses focus. I have tried using SetFocus() after the call and nothing I try sets the focus back to the dialog which called the executable.
How do you get the calling application to retain focus after a call to ShellExecute?
Thanks,
Steve
|
|
|
|
|
change
ShellExecute( hwnd,"open",
"C:\\program files\\winamp\\winamp.exe" ,
"c:\\song.mp3",
"c:\\program files\\winamp\\",
SW_SHOWMINNOACTIVE );
to
ShellExecute( GetDesktopWindow(),"open",
"C:\\program files\\winamp\\winamp.exe" ,
"c:\\song.mp3",
"c:\\program files\\winamp\\",
SW_SHOWMINNOACTIVE );
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
I tried your suggestion and it yields the exact same result.
I was about to edit my post but you responded so promptly. Thanks.
My dialog application is using the whole desktop. When I call ShellExecute the task bar comes to the top over the bottom of my application and stays that way until I click on it.
Any other ideas?
|
|
|
|
|
well did ya try putting the hwnd to null.
humm well besides this i am out of idea, may be the winamp is tring to put itself up. May be some settings in the winamp itself.
does the same problem accours with other applications??
Well i am sorry, i am out of ideas.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Yes, I tried the putting hwnd to NULL and yes it does it for all executables.
Must be a strange behavior of a dialog based application.
Thanks for your suggestions.
Steve
|
|
|
|
|
Have you tried using CreateProcess() instead of ShellExecute() ?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
No I have not but I will try anything at this point.
|
|
|
|
|
I have written a program which will accept only 20 connections to the server port. If connection goes beyond 20 then below mentioned code will be executed which is in while loop
memset(cSendBuf,' ',23);
memset(&sd, '\0', 23);
printf("\nRejecting Excess Client %s ...\n",inet_ntoa(sockAddr.sin_addr));
strcpy(sd.cstrmsg,"Rejecting Excess Client");
strcpy(cSendBuf,"");
printf("sd.cstrmsg is ;%s\n",sd.cstrmsg);
memcpy(cSendBuf,sd.cstrmsg,23);
int x=send(sock_id,cSendBuf,23,MSG_NOSIGNAL);
printf("x is %d\n",x);
close(sock_id);
continue;
Problem is socket closes before data is sent to client, so client fails to receive data (even though close is after send). Is there is any way to wait till client receives data and then close the socket or other solution like that. If i put sleep(2); before close then it works fine. Using sleep is not a right way to wait.
Waiting for the reply.
|
|
|
|
|
You should create the socket in blocking mode.
|
|
|
|
|
below is code to create, bind, listen socket.
please tell me where i have to change the code (i am new to socketing).
sockAddr.sin_family=AF_INET;
sockAddr.sin_addr.s_addr=INADDR_ANY;
sockAddr.sin_port=htons(iPortNo);
addrLen=sizeof(struct sockaddr_in);
if((serverSocket=socket(AF_INET,SOCK_STREAM,0))== -1)
{
printf("Failed to create Socket\n");
return -1;
}
else
printf("Socket created successfully\n");
rc = setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR,(char *)&optval, sizeof(optval));
if(bind(serverSocket,(struct sockaddr_in*)&sockAddr,sizeof(sockAddr))==-1)
{
printf("Failed to bind at port %d\n",iPortNo);
return -1;
}
else
printf("Binding at port %d done successfully\n",iPortNo);
if(listen(serverSocket,1000) == -1)
{
printf("Failed to listen at port %d\n",iPortNo);
return -1;
}
else
printf("Listening at port %d\n",iPortNo);
while(1)
{
pthread_mutex_init(&tCounter.mutex,NULL);
sock_id = accept(serverSocket,(struct sockaddr_in*)&sockAddr,&addrLen);
..........................
..........................
}
Waiting for the reply
|
|
|
|
|
Yes it is a blocking socket. I noticed two potential problem:
1) you use close instead of closesocket.
2) You should set the option SO_LINGER to non-zero, so closesocket will wait for the transmit queue to be empty.
Sorry for the delay in the answer, I am very busy lately.
Regards
Paolo
|
|
|
|
|
Hi,
How to insert property sheet into a form view.I am using Embedded VC++. Can u give me some sugg?
Thanks
JP
|
|
|
|
|
I dont know about eVC++, but i would do it this way. Put a static frame on the formview dialog, then in the initialization fot the formview i will create the propertysheet, add the pages to it, get the rectangle are of the static rectangle and move the propertysheet to that rect. Thats it,
also note that the parent of the propertysheet should be the formview window handle.
Hope i solved ur problem in some way.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
|
|
Hi,
I have a dialog based application in which i have created a toolbar . now i want to display tooltips for each of the items in the toolbar.
I have tried the following :
CToolTipCtrl Tips;
Tips.Create(this);
Tips.AddTool(GetDlgItem(ID_TEST),"Click to start transferring e-mails");
Tips.Activate(TRUE);
In PretranslateMessage:
Tips.RelayEvent(pMsg);
i have also tried:
CWnd *pwnd=AfxGetApp()->m_pMainWnd->GetDlgItem(IDR_TOOLBAR);
Tips.Create(this);
Tips.AddTool(pwnd->GetDlgItem(ID_TEST),"Click to start transferring e-mails");
Tips.Activate(TRUE);
but to no success .... can you please help me...
Thanking you
Regards
Satadru Karjee.
|
|
|
|
|
|
Hi everybody,
Here is a brain teaser for all. I have a class hierarchy as below.
The code compiles with a warning (C4355). During run time i get a run time error
R6025 - Pure virtual function call.
#include <iostream.h>
class CBase
{
public:
CBase()
{
}
~CBase()
{
}
virtual void Display() = 0;
};
class CTemp
{
public:
CTemp()
{
}
CTemp(CBase &pBase)
{
// Call the Overrriden function here.
pBase.Display();
}
~CTemp()
{
}
};
class CDerived : public CBase
{
public:
CDerived()
: tempObj(*this)
{
}
~CDerived()
{
}
CTemp tempObj;
virtual void Display()
{
}
};
void main()
{
CDerived obj;
}
The error here is because the base class pointer is calling a Pure virtual function,
which does not have any implementation.
How should i make the code work, without making much code change ?
Or are there any compiler options, which will circumvent the problem ?
Iam using Visual Studio 6.0 as the IDE for compilation.
Any help will be greatly appreciated.
Thanks in advance,
Saleem.
|
|
|
|
|
Try this:
CTemp(CBase *pBase)
{
pBase->Display();
}
John
|
|
|
|
|
here is the working solution
class CBase<br />
{<br />
public:<br />
<br />
CBase()<br />
{ <br />
}<br />
<br />
~CBase()<br />
{<br />
}<br />
<br />
virtual void Display() = 0;<br />
};<br />
<br />
<br />
class CTemp<br />
{<br />
public:<br />
<br />
CTemp()<br />
{<br />
}<br />
<br />
CTemp(CBase *pBase)<br />
{<br />
pBase->Display();<br />
} <br />
~CTemp()<br />
{<br />
}<br />
<br />
};<br />
<br />
class CDerived : public CBase<br />
{<br />
public:<br />
<br />
CDerived()<br />
{<br />
tempObj = new CTemp(this);<br />
} <br />
~CDerived()<br />
{<br />
}<br />
<br />
CTemp* tempObj;<br />
<br />
virtual void Display()<br />
{<br />
printf("hello World i am virtual");<br />
}<br />
<br />
};<br />
<br />
<br />
void main()<br />
{<br />
CDerived obj;<br />
}
changes are in bold.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
The real solution is NOT to call a virtual function from the constructor. ISTR that in the C++ specification, it explicitly mentions this; the object construction is not yet complete, so there is no guarantee what (if anything) is in the vtable. More than likely it is the address of the function for the class you're deriving from. If that happens to be a pure virtual function, you're sunk.
Steve S
|
|
|
|
|
Steve S wrote:
the object construction is not yet complete, so there is no guarantee
When the constructor is executing the class initialization is over
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
But not for any inheriting classes, as the compiler has to construct the base classes first. If you call a virtual function in a base class constructor, the inherited class constructor has yet to complete, so it does not have a valid vtable pointer to the inherited class functions.
MS put this very problem into the CDocTemplate class, where they call a virtual function in the base class constructor.
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|