|
Thanks for the tip. It's a good idea
|
|
|
|
|
No problem. If you look into the windows api's, you will find that many of the functions are declared like this, you either have to set up a struct or you get one back. My current project calls on the need of dealing with several arrays all relating to the same info, so instead of passing all the arrays and sizes to each function, I simply pass a pointer to a struct.
|
|
|
|
|
If the array is allocated on the heap, sizeof behaves differently than it does if it was on the stack.
int i = 0;
float stackArray[5];
i = sizeof(stackArray) / sizeof(stackArray[0]);
float* heapArray = new float[5];
i = sizeof(heapArray) / sizeof(heapArray[0]);
int myFunction(float* myArray)
{
return sizeof(myArray) / sizeof(myArray[0]);
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I have an MDI application.
In these , i have a model-less dialog box with a button which when clicked opens up a child window in the background of the dialog box
How can i make the child window to appear foreground and dialog box to appear
background when the button is clicked
|
|
|
|
|
Hi,
Could you be more specific, please? You said that it is an MDI application, though is your dialog-box created as standalone window, or as MDI-Child? If your second dialog-box is created as MDI child inside MDI frame, it can't be displayed in foreground.
Regards
|
|
|
|
|
I have a dialog box on start-up of the application .
when a button is clicked on the dailog box , it pops up an MDI child window which is displayed at the background.
|
|
|
|
|
Hi,
Veeresh Hiremath wrote: pops up an MDI child window
and this is why it is displayed in the background. As long as you create it as MDI child it is supposed to be displayed below your dialog box, though in the foreground of the parent MDI frame. This is exactly how MDI works.
Also, "it pops up" is not really the case here, since MDI child windows aren't popped up, these are just MDI frame's child windows, and if you want window to be popped up, you have to obey MDI and create it as popup.
Regards
|
|
|
|
|
Thanks for the information.
|
|
|
|
|
I want to know the path of favourites of user who is logged in of system?
|
|
|
|
|
Hi
SHGetSpecialFolderLocation with CSIDL_FAVORITES
-----------
Mila
|
|
|
|
|
of course should be SHGetSpecialFolderPath and not SHGetSpecialFolderLocation
-----------
Mila
|
|
|
|
|
char szPath[255];
if(SUCCEEDED(SHGetSpecialFolderPath(NULL,szPath,CSIDL_FAVORITES, 0)))
{
MessageBox(szPath);
}
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hi Everybody,
I'd like to know how to get the windows installed drive?
If I installed Windows in C: drive, the result should be "C:".
Is there any API available to get this?
Thanks in advance,
Sarvan AL
*** Live Lift To Its Fullest ***
|
|
|
|
|
Use
GetWindowsDirectory()<br />
<pre> char cBuf[255];
GetWindowsDirectory(cBuf,255);
MessageBox(cBuf); </pre> <br />
This will give you the path to windows directory however. <br />
<br />
<div class="ForumSig"><font face="Verdana" color="Crimson" size="1.4">Nobody can give you wiser advice than yourself. - Cicero</font></div>
|
|
|
|
|
|
How to get the System Name & IP Address in Linux using C.
I m using gcc compiler.
I tried it using code for getting System Name & IP in Window , but output I am getting is "localhost.localdomain" & "127.0.0.1" (but system has IP).
Also how to get/check the System Name in Linux Environment?
Plz. help me.
Sorry I didn't found the exact Community for my que.
|
|
|
|
|
Hi,
You have to include following headers: <netdb.h> <arpa/inet.h>
By using gethostbyname(name) you will get hostent structure filled with available information about host under the name specified as parameter.
By using gethostbyaddr(addr, len, type) you will get hostent structure filled with available information about host under specified IP address.
In order to get system name, you can use h_name member of hostent structure.
To get IP address/es, you can use h_addr_list member of hostent structure to list all associated addresses or use h_addr pointer to first available address.
Example:
struct hostent *lphe;
lphe = gethostbyname("mylinux");
if (!lphe) {
} else {
printf("Computer name is : %s\nIts IP address is: %s", lphe->h_name, inet_ntoa(lphe->h_addr));
}
Hope that helps a bit...
Regards
|
|
|
|
|
Galatei wrote: lphe = gethostbyname("mylinux");
How / From where I can get this name ("mylinux")?
Galatei wrote: inet_ntoa(lphe->h_addr)
It is giving error that Can't convert to char* from in_addr.
|
|
|
|
|
Aniket Salunkhe wrote: How / From where I can get this name ("mylinux")?
#include <unistd.h>
#include <limits.h>
char name[HOST_NAME_MAX+1];
int result;
result=gethostname(name, HOST_NAME_MAX+1);
|
|
|
|
|
Aniket Salunkhe wrote: name ("mylinux")?
That was just an example.
To get the name of your system, simply call getenv("HOSTNAME") which will give you full name of your system in return.
example:
printf("HOSTNAME: %s\n", getenv("HOSTNAME"));
In order to read address of particular interface (eg. eth0), you may do something like this:
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int getifaddr(char *pifname, struct sockaddr_in* psai)
{
int s;
struct ifreq ifr;
struct sockaddr_in *saitmp = (struct sockaddr_in*)&ifr.ifr_addr;
if (!pifname || !psai)
return -1;
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0)
return -2;
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, pifname);
saitmp->sin_family = AF_INET;
if (ioctl(s, SIOCGIFADDR, &ifr) != 0)
return -3;
memcpy(psai, saitmp, sizeof(struct sockaddr_in));
return 0;
}
then use inet_ntoa function to get address string.
example:
#include <stdio.h>
#include <string.h>
int main(void)
{
struct sockaddr_in sai;
if (!getifaddr("eth0", &sai))
printf("IP: %s\n", inet_ntoa(sai.sin_addr));
else
perror("getifaddr error!\n");
}
Hope that helps.
Regards
|
|
|
|
|
Thanks.
Now I am getting proper System IP in Linux; & also the System Name.
|
|
|
|
|
Hi!
there is a ListControl in my project (FormView).
if user selects an Item or more, rows of this items in ListControl, take different color.
But, if user kill focuse of list control, color of this items change to same color of other items.
what do i do to solve this problem?
Zo.Naderi-Iran
|
|
|
|
|
Do you need to add the LVS_SHOWSELALWAYS style?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i add this style, but it isn't useful.
Zo.Naderi-Iran
|
|
|
|
|
excuse me, i find Show selection always in style tab of properties of List control and select this property, now my problem is solved.
Thanks alot
Zo.Naderi-Iran
|
|
|
|