|
In many controls (like a standard listbox) the focus state and selected state are set at the
same time.
Having both states gives custom controls a way to indicate keyboard focus without an item being selected or vice-versa.
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
In the standard listbox rendering, Focus typically draws a dashed rect around the "current" item and Selected shows the item in color. The difference is useful if you want to e.g. keep the Selected item highlighted when the listbox is not focused.
Usually only the affected items are redrawn. For example, if you have item 1 selected and click on item 2, you'd get draw messages for item 1 (with the selected flag cleared) and item 2 (with the selected flag set), but no draw msgs for items 0 or 3. If oyu *scroll* the listbox you'll get draw messages for all visible (either partially or fully) items, but not for those items whose rects fall outside (above/below) the window's client area.
|
|
|
|
|
Hello friends, this me back with a question. I ve got a code snippet for finding the list of systems in a LAN.It lists the computer name and the IP address. Now i wanted to know how i can find the status of the system ie. if it is active or not.
here is the piece i used to found the systems:
for ( unsigned int 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);
ptr = (struct in_addr *) host->h_addr_list[0];
int a = ptr->S_un.S_un_b.s_b1; // 211.40.35.76 split up like this.
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
lpszSystemInfo = tchBuffer;
// Get and display the user name.
GetUserName(lpszSystemInfo, &cchBuff);
strTemp.Format("%s --> %d.%d.%d.%d",strFullName,a,b,c,d);
pList->AddString(strTemp);
}
}
}
this is a downloaded code friends. but still i want to know how.if we can find the IP address, then there must be a way to find its status. Pls do let me know if anyone of you know this.Thanks (in anticipation)
Malini
|
|
|
|
|
Malini Nair wrote: Now i wanted to know how i can find the status of the system ie. if it is active or not.
(If I understand your question correctly ...)
What about the function:
FILE *_popen(const char *command,const char *mode)
You can uses this function to ping the other machine, and know the status.
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
char psBuffer[128];
FILE *pPipe;
if( (pPipe = _popen( "ping 192.168.0.1", "rt" )) == NULL )
exit( 1 );
while( !feof( pPipe ) )
{
if( fgets( psBuffer, 128, pPipe ) != NULL )
printf( psBuffer );
}
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
}
Hope this helps ..
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
How did you get your array of NETRESOURCE structs? If an item is in the array then I would assume
it is active. What do you mean by active status?
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
Im having a problem with creating an object of a crystall report. In C# we can create an object of a crystal report by simply
Report1 rpt = new Report1();
but in c++ how to do that? c++.net doesnot allow it. if some one knows how to create an object of a report pls let me know. please. thanks.
Pubudu
|
|
|
|
|
Hi everybody!
I downloaded a project.When I compiled it, I got an error saying 'Cannot open Iphlpapi.lib'.
Then i downloaded the library file and included it in the project.
Still it shows this error!
I dono what has to be done!
Please help me!
Thanks in advance!
|
|
|
|
|
you have to tell the linker where to find the .lib file.
look in your project settings, and reach the linker "additionnal libraries" option...
|
|
|
|
|
Do you have the latest platform SDK installed.
To include a lib file you can also use...
Another option is use #pragma comment( lib, "Iphlpapi.lib" )
|
|
|
|
|
Nibu babu thomas wrote: #pragma comment( lib, "Iphlpapi.lib" )
Why is that called "comment" any relavance?
286? WOWW!
|
|
|
|
|
_8086 wrote: Why is that called "comment" any relavance
From MSDN:
#pragma comment( comment-type [, commentstring] )
Places a comment record into an object file or executable file. The comment-type is one of five predefined identifiers, described below, that specify the type of comment record. The optional commentstring is a string literal that provides additional information for some comment types. Because commentstring is a string literal, it obeys all the rules for string literals with respect to escape characters, embedded quotation marks ("), and concatenation.
lib:
Places a library-search record in the object file. This comment type must be accompanied by a commentstring parameter containing the name (and possibly the path) of the library that you want the linker to search. Since the library name precedes the default library-search records in the object file, the linker searches for this library just as if you had named it on the command line. You can place multiple library-search records in the same source file; each record appears in the object file in the same order in which it is encountered in the source file.
|
|
|
|
|
Thanks I get it now.
286? WOWW!
|
|
|
|
|
_8086 wrote: Thanks I get it now.
Really !
|
|
|
|
|
Dear,
I am trying to create a MFC program to scroll some text.
I have already used the double buffering technology, however, there is still some flicker...
I want to do one without any flicker.
Is anyone who can help me???
Thanks a lot.
Here is my code
struct News
{
CString strNews;
int pos;
int initpos;
BOOL bDecrease;
};
CList<news*,news*> m_News;
void CTextScroller::OnTimer(UINT in)
{
if(in == 0)
{
CClientDC dc(this);
CRect rectClient;
GetClientRect(&rectClient);
MoveTextToLeft(&dc, rectClient);
}
CStatic::OnTimer(in);
}
void CTextScroller::MoveTextToLeft(CDC* pDC, CRect& r)
{
int count = m_News.GetCount();
if(!count)
return;
CDC memDC;
memDC.CreateCompatibleDC(pDC);
if(m_BmpMain.m_hObject == NULL)
{
m_BmpMain.CreateCompatibleBitmap( pDC, r.Width(), r.Height() );
}
memDC.SelectObject(&m_BmpMain);
memDC.SelectObject(&m_font);
memDC.SetBkMode(TRANSPARENT);
memDC.SetTextColor(m_TextColor);
News *_news = NULL;
CSize size;
POSITION pos = m_News.GetHeadPosition();
memDC.FillSolidRect(&r,m_BkColor);
while(pos)
{
_news = m_News.GetNext(pos);
if(!_news)
return;
size = memDC.GetTextExtent(_news->strNews);
if(_news->bDecrease)
_news->pos--;
if(_news->pos < r.left - size.cx)
continue;
//memDC.DrawText(_news->strNews,CRect(_news->pos, 0, _news->pos + size.cx, size.cy),DT_LEFT);
memDC.TextOutW(_news->pos, 0, _news->strNews);
}
pDC->BitBlt(0, 0, r.Width(), r.Height(), &memDC, 0, 0, SRCCOPY);
}
|
|
|
|
|
please read this[^] and edit your message to use <pre></pre> tags when posting code
|
|
|
|
|
As toxcct mentioned, please reformat your post so we can read your code without our eyes
bleeding
You shouldn't be getting any flicker unless maybe the window you're blitting to is redrawing
its background.
You're using double buffering so there's no need to set the BkMode of the memory DC to
TRANSPARENT.
Also, a possibly simpler solution is to use ScrollWindowEx to scroll a windows contents and then
only the newly exposed portion of the window needs to be repainted. No flicker and no double
buffering required
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
I'm standing right here:
CString cs;
void CNotePadApp::OnFileOpen()
{
}
void CNotePadView::OnDraw(CDC* pDc)
{
CNotePadDoc* pDoc = GetDocument();
pDc->TextOutA(0,0,csText,csText.GetBufferLength());
286? WOWW!
|
|
|
|
|
Well since you are using the Doc/View architecture, the usual practice is to store the string in a member variable of your CDocument derived class (CNotePadDoc??).
This can then be easily accessed from your view.
<br />
void CNotePadApp::OnFileOpen()<br />
{<br />
CString strText = _T("Some string ");<br />
CNotPadDoc* pDoc = GetDocument();<br />
pDoc->SetMyString(strText);<br />
}<br />
<br />
..<br />
void CNotePadView::OnDraw(CDC* pDc)<br />
{<br />
CString csText;<br />
CNotePadDoc* pDoc = GetDocument();<br />
<br />
csText = pDoc->GetMyText();<br />
pDc->TextOutA(0,0,csText,csText.GetBufferLength());<br />
..<br />
I Dream of Absolute Zero
|
|
|
|
|
You open a file, using the "open" in the winapp window menu. Now you store the content in a string.. Now, how do you send it to the view. Please note, you are now away from the view class. Where is the view class's object created?
In general the question goes like this:
You are inside a class far away from the view class. How do print a string from the far away class into the view(The client window that's displays content). You get me now?
286? WOWW!
|
|
|
|
|
Thanks RChin, I'll try that.
286? WOWW!
|
|
|
|
|
|
Thanks dude!
----------------------------
286? WOWW!
|
|
|
|
|
Wow!!! Just checked very nice articles! thanks for sharing!
----------------------------
286? WOWW!
|
|
|
|
|
hi
I want write the code for :
char *strcpy(char *s1 , const char *s2 )?
char *strncpy(char *s1 , const char *s2 , int size)?
char *strcat( char *s1 , const char *s2 )?
char *strncat( char *s1 , const char *s2 , int size )?
int *strcmp( const char *s1 , const char *s2 )?
int *strncmp( const char *s1 , const char *s2 , int size)?
help me please
|
|
|
|
|
what's your question exactly ? you want to rewrite thos function ?
what for ?
moreover, if you work with C++ strings, you'd better forget those old char*. they are a legacy from the C language, kept for compatibility.
however, you should use the std::string class instead; which class proposes all the functionnality you want to redevelop here (if i get you well)
|
|
|
|