|
CEdit::SetLimitText
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"
|
|
|
|
|
Hi there,
I fill a ListBox (AddString(str)) from a loop.
When ListBox become full the vertical scrollbar will be appeared.
But I want to do somthing to move the scroll to down in order to the last item become appeared always.
How can I do this?
This functionality is very simple when we use CListControl, because there is a method called Scroll(...) in CListControl class for this reason.
Thanks.
|
|
|
|
|
you have to do it manually:
something like:
void DlgFlexListSelectValue::SetHorizontalScrollBar(){<br />
CString str;<br />
CSize sz;<br />
int dx = 0;<br />
TEXTMETRIC tm;<br />
CDC* pDC = m_valueList.GetDC();<br />
CFont* pFont = m_valueList.GetFont();<br />
<br />
CFont* pOldFont = pDC->SelectObject(pFont);<br />
pDC->GetTextMetrics(&tm); <br />
<br />
for(int i = 0; i < m_valueList.GetCount(); i++){<br />
m_valueList.GetText(i, str);<br />
sz = pDC->GetTextExtent(str);<br />
<br />
sz.cx += tm.tmAveCharWidth;<br />
<br />
if(sz.cx > dx){<br />
dx = sz.cx;<br />
}
}
<br />
pDC->SelectObject(pOldFont);<br />
m_valueList.ReleaseDC(pDC);<br />
m_valueList.SetHorizontalExtent(dx);<br />
}
call the function when you have loaded the listbox.
it's on MSDN somewhere.
good luck.
No hurries, no worries.
|
|
|
|
|
Thank you.
but I don't have problem with horizontal scrolling
|
|
|
|
|
idd, I misread, my apologies .
good luck though.
PS: there should be a function like SetScrollPos or something.
No hurries, no worries.
|
|
|
|
|
m_list.SetCurSel( m_list.AddString(s) );
will work for u.
It will autimatically scroll to last item and will make is selected.
Jetli
Constant Thing In World Is Change.
|
|
|
|
|
i seem to have probz with my dialog based application.....my main dialog callz a modal dialog (which basically loadz some imagez into the screen) and then when i close thiz modal dialog....i see that the memory is not freed!!!!!(i came to view that from taskmanager)....each time i call this modal dialog,it increases by a definitive amount(520kb).....i have freed the dc memery and also even the pointer dynamically created for the modal dialog.....HELP....herez the code.....
THIZ IZ HOW I HAVE CALLED THE MODAL DIALOG FROM MY MAIN DIALOG!!!!!
CMyPresetViewer *PresetViewerDlg = new CMyPresetViewer;
if(PresetViewerDlg->DoModal()==IDOK)
{
}
delete PresetViewerDlg;
THIZ IZ THE CODE THAT IZ WRITTEN IN THE MODAL DIALOG
void CMyPresetViewer::OnStatic1()
{
ReleaseDC(m_dcPresetViewerDialog);
delete m_dcPresetViewerDialog;
AfxMessageBox("done");
CDialog::OnOK();
}
BOOL CMyPresetViewer::OnInitDialog()
{
CDialog::OnInitDialog();
m_DragOn=FALSE;
CClientDC dc(this);
m_dcPresetViewerDialog->CreateCompatibleDC( &dc );
m_hBmpNew = (HBITMAP) LoadImage(
AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDB_BITMAP59),
IMAGE_BITMAP,
0,
0,
LR_CREATEDIBSECTION);
if( m_hBmpNew == NULL )
{
AfxMessageBox("Load Image Failed");
}
else {
m_st0.GetClientRect( &rectStaticClient );
rectStaticClient.NormalizeRect();
m_size.cx=rectStaticClient.Size().cx;
m_size.cy=rectStaticClient.Size().cy;
m_size.cx = rectStaticClient.Width();
m_size.cy = rectStaticClient.Height();
m_st0.ClientToScreen( &rectStaticClient );
ScreenToClient( &rectStaticClient);
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(*m_dcPresetViewerDialog, m_hBmpNew ) );
offsetx= rectStaticClient.left;
offsety= rectStaticClient.top;
}
return TRUE;
}
void CMyPresetViewer::OnCancel()
{
CDialog::OnCancel();
}
void CMyPresetViewer::OnPaint()
{
CPaintDC dc(this);
dc.BitBlt(offsetx,offsety,m_size.cx,m_size.cy,m_dcPresetViewerDialog, 0, 0,SRCCOPY);
}
}
CAN ANYONE TELL ME WHERE I HAVE GONE WRONG!!!!!
I SEEM TO HAVE FREED AL THE RESOURCES.....
HEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEELP!!!!!
thankz in advance.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Let me guess, the bitmat is about 520 KB in size? I suggest the next time u use an API, you look at it in MSDN first, because that's what caused your memory leak! Take a look here[^] and see what you have to do...
I also got the blogging virus..[^]
|
|
|
|
|
READ IT A MILLON TIMEZ!!!!!if ur suggesring LR_SHARED!!!thatz not it.....and by the way.....itz not a cut paste code.....and moreover i didnt put it to be graded!!!!!
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
I don't see you releasing the old bitmap!
Take a closer look at: VERIFY(m_hBmpOld = (HBITMAP)SelectObject(*m_dcPresetViewerDialog, m_hBmpNew ) ); and wonder where you release the handle of the old bitmap.
I also got the blogging virus..[^]
|
|
|
|
|
u know what,,,,,i even did that!!!!!(i beleive u r talking abt DeleteObject() ) ....thatz not just it!!!!!
thanx anyway!!!!!
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Why are you creating PresetViewerDlg on the heap? From what you've shown, it is unnecessary.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
How to get mouse cursor hot spot from handle to the cursor?
modified 11-Mar-21 21:01pm.
|
|
|
|
|
GetIconInfo()
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Message Closed
modified 11-Mar-21 21:01pm.
|
|
|
|
|
Maksim Goleta wrote:
It gives me the hot spot on the screen, how do I get the spot within the cursor so I can draw the cursor properly aligned?
No, it gives you the hotspot within the cursor. At least it always has for me.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
How to write script for compilation of VS.NET project. Languange of the script is not important, I just need working solution.
|
|
|
|
|
Is there a way to programmatically set XP's feature of hiding tray icons to always showing? My client wants to make sure their icon is always showing in the tray. I know you can manually set that, but they want it done automatically for the user.
Thanks
|
|
|
|
|
Suppose the item is selected,
how can i make it not be selected by function
Thanks
|
|
|
|
|
Look up SetItemState in MSDN.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
i looked but i did not find.
|
|
|
|
|
|
I Believe that you are looking for the code for Unselect the selected CListCtrl Item.
Here is small Code listing to get that:-
POSITION pos=<list ctrl var>.GetFirstSelectedItemPosition();
while(pos)
{
int nSelected=<list ctrl var>.GetNextSelectedItem(pos);
<list ctrl var>.SetItemState(nSelected,LVIS_SELECTED,0);
}
"I Think Believe this Will Help"
[Vote One Here, Complete my Survey....]
<h5
alok="" gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi,
I'm trying to set up multycast connection between few PC's.
The problem is that after the client send the data (let's say - "hello world")
at the first time,select() ans accept() are blocking my apllication,until the clinet tryies to connect again.
I was told to try to setup the socket to non blocking mode,using the ioctlsocket() and i tried this:
For each listening port,i call this function:
SOCKET CMultycast_serverDlg::CreateTCPServerSocket(int PortNumber)
{
int Socket = 0;
struct sockaddr_in echoServAddr;
int bind_res;
WSADATA wsaData;
CString string;
unsigned long argp = 1;
if(WSAStartup(0x202,&wsaData) == SOCKET_ERROR)
{
AfxMessageBox(" Error : WSAStartup() has failed ");
return -1;
}
Socket = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
if(Socket == INVALID_SOCKET)
{
string.Format(" Unable to create socket for port #%d ",PortNumber);
AfxMessageBox(string);
return -1;
}
ioctlsocket(Socket , FIONBIO , &argp);
memset(&echoServAddr,0,sizeof(echoServAddr));
echoServAddr.sin_family=AF_INET;
echoServAddr.sin_addr.S_un.S_addr=htonl(INADDR_ANY);
echoServAddr.sin_port=htons(PortNumber);
bind_res = bind(Socket,(struct sockaddr*)&echoServAddr,sizeof(echoServAddr));
if(bind_res == SOCKET_ERROR)
{
string.Format(" Unable to create bind to local address for port #%d ",PortNumber);
AfxMessageBox(string);
return -1;
}
if(listen(Socket,MAXPENDING) == SOCKET_ERROR)
{
string.Format(" Unable to listen to socket in port #%d ",PortNumber);
AfxMessageBox(string);
return -1;
}
return Socket;
}
But the problem still appear.
Is there any toturial about this problem?
With best regards.
Eli
|
|
|
|
|
See the Winsock Programmer's FAQ[^].
In your particular case I would recommend using blocking sockets, but on a worker thread instead of in your main user interface thread.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|