|
You can get the class name from GetClassName. Then you can cast your CWnd to the appropriate derived class.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
|
a simple question...
how to generate random numbers by rand() within a given range...
let say between 20 and 40
thanks
|
|
|
|
|
Hello,
Does:
srand( (unsigned)time( NULL ) );
int nNumberBetween20And40 = (rand() % 20) + 20;
(rand() % 20) gives you a number between 0 and 20.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I need to get a fully qualified name of the host machine.(Eg: Shivaeb.invent.co.in)
I tried using gethostname() API, but it is returning only the machine name(Eg:Shivaeb) not the fdqn name(Shivaeb.invent.co.in).
Could any one suggest any API or any logic to get the fully qualified name of the PC?.
Thanks & Regards,
Shiva
|
|
|
|
|
use this code
char ah[100]={0};
gethostname(ah,100);
hostent* kk=NULL;
kk=gethostbyname(ah);
|
|
|
|
|
Thank you for your reply.
I tried with that code but what is happening is even hostent h_name member is also having the same hostname as returned by gethostname() API.
There is one more API getnameinfo(), which this also i could not get the fully qualified name of the host machine.
Could you please suggest me some other solutions?.
Thanks & Regards,
Shiva
|
|
|
|
|
Shiva,
I wonder how it is not working. I've tested code on my m/c.
see description of hostent on MSDN, too.
h_name
Official name of the host (PC).If using the DNS or similar resolution system, it is the Fully Qualified Domain Name (FQDN) that caused the server to return a reply. If using a local “hosts” file, it is the first entry after the IP address.
I've given up.
leaving for the day and weekend. Happy ganesh chaturthi
-- modified at 9:36 Friday 16th September, 2005
|
|
|
|
|
prasad_som wrote:
leaving for the day and weekend. Happy ganesh chaturthi
Happy Ganesh Chaturthi, Dear
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hi,
Is there any thing with DNS Server configuration?.Because i m not all getting fully qualified through all the API's.
One more doubt.How do we know host name is get from the 'hosts' file or from DNS Server?.
I tried checking nslookup command. It is not responding with my machine name only.but when i try with fully qualified name of the host, it is getting the response.
Could you please check your machine how it is responding with nslookup utility?.
Thanks & Regards,
Shiva
|
|
|
|
|
I know that it have 7 layers which is Physical, data link, network, transport, session, and presentation. Can tell me mewtocol is in which layer?
|
|
|
|
|
I want a simple code which display popup messgaes from
task bar at a particular time.
Plz give a simple solution.,
(Plz do it in a simple dialog)
Don't give unnecessary code.
Praveen Chowdam Kumar
|
|
|
|
|
|
Hi
I have a problem re tab control. I use onClick to detect a user selection but onClick gives me the last tab and not the selected tab. I have tried using TCN_SELCHANGE but this one does not reflect any changes. I have actually used this method with vc6 and it works. But its not working on the VS2003.
UpdateData(TRUE);
ctab = m_tab.GetCurSel(); // ctab is to display the selected tab id
// refreshing of the appropriate tab details is done here
switch(ctab)
{
case 0://refesh tab 0
break;
case 1;// refresh tab 1
break;// ...etc
}
UpdateData(FALSE);
anyone know what might be the problem?
Thanks.
Thomas
|
|
|
|
|
can u please tell me how to manipulate with one window in a dialogbox that looks like a grid of editboxes containing many rows,columns ( sth like the local variables window which appear in vc++ while doing step debugging).what kind of a control is it? for an edit box u sing the GetWindowText we can get its contents. pleas help me how to get the many values present in that grid object(window).
|
|
|
|
|
You can use a CListCtrl. Apply the "ReportView" and "NoColumnHeader" Styles and Gridlines as ExStyle.
MS
|
|
|
|
|
tejaswi_teja wrote:
can u please tell me how to manipulate with one window in a dialogbox that looks like a grid of editboxes containing many rows,columns
Take a look at this, should give you the functionality you desire.
MFC Grid control 2.25[^]
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
I developed one scheduler application.
When I run this applcation (scheduler.exe)it is running.
Next If I start another (scheduler.exe) is running.
How to stop another process .,when One process is in running.
Plz give reply urgently.
Praveen Chowdam Kumar
|
|
|
|
|
Yesterday I solved this problem. Try the following link.
http://www.codeproject.com/cpp/avoidmultinstance.asp
OR
Try following solution.
Insert the following code in YourApp::InitInstance().
bool AlreadyRunning;
HANDLE hMutexOneInstance = ::CreateMutex( NULL, TRUE,
UNIQUE_GUID);
AlreadyRunning = (GetLastError() == ERROR_ALREADY_EXISTS);
if (hMutexOneInstance != NULL)
{
::ReleaseMutex(hMutexOneInstance);
}
if ( AlreadyRunning )
{ /* kill this */
AfxMessageBox("Application instance already running");
HWND hOther = g_hWnd;
if (hOther != NULL)
{ /* pop up */
::SetForegroundWindow(hOther);
if (IsIconic(hOther))
{ /* restore */
::ShowWindow(hOther, SW_RESTORE);
} /* restore */
} /* pop up */
return FALSE; // terminates the creation
} /* kill this */
// ... continue with InitInstance
UNIQUE_GUID is defined as
#define UNIQUE_GUID _T("YourAppName{1C7496E6-5949-4907-9F3E-CE26ED9EEB78}")
I generated this string using GUIDGEN.EXE (Visual Studio tool). String here is new string you can use it.
|
|
|
|
|
This is FAR TOO OFTEN overlooked aspect of naming synchronization objects.
If this is run from a terminal services console or as a service, that is the only instance that can work on the entire system - the mutext will be seen across all sessions. If this is started first from a terminal services session, then other sessions could also start, since the mutex will have local scope.
If you REALLY REALLY only want one instance on the enire computer, then you need to put "Global\" in front of your mutex name. If you really want each terminal services session to only run a single instance, then put "Local\" in front of your mutex name.
Services and the console terminal services session share the same scope.
So, if you want the console session to be able to run at the same time as it runs as a service, then you need a different name when it runs as as service.
From MSDN:
Terminal Services: The name can have a "Global\" or "Local\" prefix to explicitly create the object in the global or session name space. The remainder of the name can contain any character except the backslash character (\). For more information, see Kernel Object Namespaces.
Windows XP Home Edition: Fast user switching is implemented using Terminal Services sessions. The first user to log on uses session 0, the next user to log on uses session 1, and so on. Kernel object names must follow the guidelines outlined for Terminal Services so that applications can support multiple users.
Windows 2000: If Terminal Services is not running, the "Global\" and "Local\" prefixes are ignored. The remainder of the name can contain any character except the backslash character.
Windows NT: The name can contain any character except the backslash character.
Windows Me/98/95: The name can contain any character except the backslash character. The empty string ("") is a valid object name.
|
|
|
|
|
parims wrote:
How to stop another process .,when One process is in running.
In Conitnuation With Poster Above my post.... you can depend upon this wrapper class too...
http://www.codeproject.com/cpp/csingleinst.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi
You Can create mutex in Scheduler.exe in CWinApp class of MFC application with some name suppose XXXX.
and at the same time you check whether it is giving successful or fail
fail response. if it is successful then scheduler.exe is running first
time and if it is giving fail that means one instance is already running...
sonani prakash
|
|
|
|
|
if limiting your application to one instance is your need, you can try this ..
put this inside OnInitInstance()
if(FindWindow(NULL,"YourAppName")==NULL)
AfxMessageBox("1 and 1ly");
else
PostQuitMessage(0);
Regards,
V
|
|
|
|
|
NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER NEVER do this
Your GUI app will hang if another GUI app is hung!
The nearly seminal document on avoiding multiple instances is located here:
http://www.flounder.com/nomultiples.htm[^]
|
|
|
|
|
Vivekuniq wrote:
if(FindWindow(NULL,"YourAppName")==NULL)
AfxMessageBox("1 and 1ly");
else
PostQuitMessage(0);
better solution would be to try SingleTon classes or Naughter CSingleInstance class
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|