|
In addition to parameter one of SetImageList() needing to be a pointer, I'm not sure what you are trying to do with
img->Add(AfxGetApp()->hicon);
Clearly, CWinApp does not have a member named hicon, so I can only assume you meant
img->Add(hicon);
instead.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
hi ,
how can i get all of the computer name&ip in local net work .I want to get other computer names&ip (All) ? how can i do ? do you understand me ? Can you help me ?
thank you !
|
|
|
|
|
my little suggestions:
char szhostname[128];
//gethostname
if( gethostname(szhostname, 128) == 0 )
{
// get ipaddr.
struct hostent * phost;
phost = gethostbyname(szhostname);
}
//and refer to msdn
Hello World!
|
|
|
|
|
not only my computer name & ip ! all in then local network .(some groups in the network)
|
|
|
|
|
i guess it's what about WNetOpenEnum.
See msdn.
Hello World!
|
|
|
|
|
see:
// TODO: Add extra validation here
CString strTemp;
struct hostent *host;
struct in_addr *ptr; // To retrieve the IP Address
DWORD dwScope = RESOURCE_CONTEXT;
NETRESOURCE *NetResource = NULL;
HANDLE hEnum;
WNetOpenEnum( dwScope, NULL, NULL,
NULL, &hEnum );
WSADATA wsaData;
WSAStartup(MAKEWORD(1,1),&wsaData);
if ( hEnum )
{
DWORD Count = 0xFFFFFFFF;
DWORD BufferSize = 2048;
LPVOID Buffer = new char[2048];
WNetEnumResource( hEnum, &Count,
Buffer, &BufferSize );
NetResource = (NETRESOURCE*)Buffer;
char szHostName[200];
unsigned int i;
for ( i = 0;
i < BufferSize/sizeof(NETRESOURCE);
i++, NetResource++ )
{
if ( NetResource->dwUsage ==
RESOURCEUSAGE_CONTAINER &&
NetResource->dwType ==
RESOURCETYPE_ANY )
{
if ( NetResource->lpRemoteName )
{
CString strFullName =
NetResource->lpRemoteName;
if ( 0 ==
strFullName.Left(2).Compare("\\\\") )
strFullName =
strFullName.Right(
strFullName.GetLength()-2);
gethostname( szHostName,
strlen( szHostName ) );
host = gethostbyname(strFullName);
if(host == NULL) continue;
ptr = (struct in_addr *)
host->h_addr_list[0];
// Eg. 211.40.35.76 split up like this.
int a = ptr->S_un.S_un_b.s_b1; // 211
int b = ptr->S_un.S_un_b.s_b2; // 40
int c = ptr->S_un.S_un_b.s_b3; // 35
int d = ptr->S_un.S_un_b.s_b4; // 76
strTemp.Format("%s --> %d.%d.%d.%d",
strFullName,a,b,c,d);
AfxMessageBox(strTemp);
}
}
}
delete Buffer;
WNetCloseEnum( hEnum );
}
WSACleanup();
//*******************************************
I try ,but fail ! thanks all the same !
|
|
|
|
|
Hellin wrote:
I try ,but fail !
Which tells us nothing. What exactly is failing? Are you getting a compiler/linker error. Is an assertion firing? Have you stepped through the code to see exactly what is (not) happening?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
not code Error ,I say that ,only can search my own computer name &ip ,so i say I fail to !
|
|
|
|
|
What about my last question?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
How to use them and which on earth to pick ?
Thank you , anyway!
Hello World!
|
|
|
|
|
This topic was discussed previously
The chosen One
|
|
|
|
|
which page?
Thank you very much!
Hello World!
|
|
|
|
|
Please see this[^] and this[^] thread. They will answer your question.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Hi,
does anyone know a possibility to mark code (.exe .dll) as unpageable!
to prevent windows from paging these code out of the memory.
Tanks,
Eddie
|
|
|
|
|
VirtualLock(), but if you have to ask then almost certainly you shouldn't be using it.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
So does that mean that until a person learns how to use a function or an API, they shouldn't be using it? I'm curious how one goes about learning about something without first using it?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Not at all, you've over generalized. I said that about VirtualLock in particular not about API's in general.
Page locking memory is one of those things that is very seldom a good idea. The appropriate times for doing it usually occur in device drivers, and they use a different, kernel mode, API to accomplish this. Mostly people think they'll page lock parts of their application to 'improve performance' and that almost never works. Trust the memory manager to trim the working-set appropriately.
Off hand, the only legitimate reason I can think of for locking pages in a user-mode app is to prevent plaintext from being written to the pagefile in a crypto scenario, and I'm not positive it even guarentees that as expected.
Hence, unless you already know a _lot_ about how the Windows VM system works, you shouldn't be tampering with it, and if you don't know about VirtualLock then clearly you don't know enough about the VMM.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
I am trying to call menu from dialog. That menu's ID is ID_MYMENU.
When you click on this button, it will do certain thing. what i
am trying to do is to call this ID_MYMENU from dialog and do the
same thing as when you click on the ID_MYMENU. I was thinking
to use function like SendMessage(ID_MYMENU,**,**) something like this.
Please help!
Shin
|
|
|
|
|
You don't need to call the menu from a button.
If you want more than 1 GUI object to be handled by the same code, then you should just edit the message maps to point to the same function.
|
|
|
|
|
If your dialog box is modal, it could be dangerous to activate a command of the application. Anyway, here's the syntax:
CMainFrame *pFrame = AfxGetApp()->m_pMainWnd;
pFrame->SendMessage(WM_COMMAND, ID_MYMENU);
Beware that with SendMessage, the call won't return before the execution of the command.
Silence Means Death
Stand On Your Feet
Inner Fear
Your Worst Enemy
|
|
|
|
|
Thank you very much. in this way, I can save a lot of
time. however, I will be carefull with those point you
mensioned.
Thanks, again.
Shin
|
|
|
|
|
My pleasure
Silence Means Death
Stand On Your Feet
Inner Fear
Your Worst Enemy
|
|
|
|
|
I am in the midst of making a FlexGrid editable in my dialog app.
For that I am creating a floating edit box same as dimesions of a cell and then placing the box at a specific cell.
What is the correlation between coordinates
Finally i need to place the edit control(say pEdit) at a cell location using
pEdit->SetWindowPos(0,x,y,width,height);
how do I calculate x , y width and height
I tried this
int y=m_flex1.GetCellTop();
int x=m_flex1.GetCellLeft();
int width=m_flex1.GetCellWidth();
int height=m_flex1.GetCellHeight();
But values seem goofy
I need to convert twips to pixels .
so I need
1. Conversion between twips and pixels
2. Final values of x ,y , width and height !
Please help
Engineering is the effort !
|
|
|
|
|
I started doing this as an experiment for one of my projects but then I aborted the idea. Download whatever stuff I wrote from this link [^] but let me warn you that I put it there for you and I will remove it as soon as you are done downloading it. I am running out of space, that's why. Let me know how it works for you.
// Afterall, I realized that even my comment lines have bugs
|
|
|
|
|
Here's what I've done in my project:
long lCellTopTwips = m_Grid.GetCellTop();
long lCellLeftTwips = m_Grid.GetCellLeft();
long lCellWidthTwips = m_Grid.GetCellWidth();
long lCellHeightTwips = m_Grid.GetCellHeight();
long lCellTopPixels;
long lCellLeftPixels;
long lCellWidthPixels;
long lCellHeightPixels;
TwipsToPixels(lCellTopTwips,
lCellLeftTwips,
lCellTopPixels,
lCellLeftPixels);
TwipsToPixels(lCellWidthTwips,
lCellHeightTwips,
lCellWidthPixels,
lCellHeightPixels);
m_Grid.GetWindowRect(&rect);
ScreenToClient(rect);
pEdit->MoveWindow(rect.left + lCellLeftPixels,
rect.top + lCellTopPixels,
lCellWidthPixels,
lCellHeightPixels);
#define TWIPS_PER_INCH (1440.0f) //A twip is 1/1440 of an inch (from MSDN)
//////////////////////////////////////////////////////////////functionstart//
void GUI_MntTreeDlg::TwipsToPixels(long lTwipsX,
long lTwipsY,
long &lPixelsX,
long &lPixelsY)
//
// DESCRIPTION: Convert from Twips (screen independent units) to pixels
// A twip is 1/1440 of an inch (from MSDN)
//
// WARNINGS:
//
// ERRORS:
//
//////////////////////////////////////////////////////////////functionend//
{
CDC* pDC = this->GetDC();
long lPixelsPerInchX = pDC->GetDeviceCaps(LOGPIXELSX);
long lPixelsPerInchY= pDC->GetDeviceCaps(LOGPIXELSY);
this->ReleaseDC(pDC);
lPixelsX = (float)lTwipsX / TWIPS_PER_INCH * (float)lPixelsPerInchX;
lPixelsY = (float)lTwipsY / TWIPS_PER_INCH * (float)lPixelsPerInchY;
}
//////////////////////////////////////////////////////////////functionstart//
void GUI_MntTreeDlg::PixelsToTwips(long lPixelsX,
long lPixelsY,
long &lTwipsX,
long &lTwipsY)
//
// DESCRIPTION: Convert from pixels to Twips (screen independent units)
// A twip is 1/1440 of an inch (from MSDN)
//
// WARNINGS:
//
// ERRORS:
//
//////////////////////////////////////////////////////////////functionend//
{
CDC* pDC = this->GetDC();
long lPixelsPerInchX = pDC->GetDeviceCaps(LOGPIXELSX);
long lPixelsPerInchY= pDC->GetDeviceCaps(LOGPIXELSY);
this->ReleaseDC(pDC);
lTwipsX = (float)lPixelsX * TWIPS_PER_INCH / (float)lPixelsPerInchX;
lTwipsY = (float)lPixelsY * TWIPS_PER_INCH / (float)lPixelsPerInchY;
}
|
|
|
|