|
Hi, I'm working on an app using a view class based on CScrollView. As the doc is BIG, I've hit the 32768 'limit' of SetScrollSizes(). I'm sure I remember seeing an article on CP about getting around this problem, but can I find it ?? Can someone point me in the right direction please !! ?
Doug
|
|
|
|
|
Use SetScrollInfo instead.
Software Zen: delete this;
|
|
|
|
|
Hi Gary, Yes, I've just stumbled over that and am now over the problem. Thanks, Doug
Doug
|
|
|
|
|
Can someone please explain 1) the effect of "op" in each of these three map initializations below, 2)why op needs to be a class or struct as an overloaded () operator , and 3) why when I use #3 I loose the ability to access an element using map[key], such as ++map[key]. Thanks!
1) map<key, elem,="" op=""> m;
2) map<key, elem=""> m(op);
3) map<key, elem,="" op=""> m(op);
Where I've seen these for reference:
1) The C++ Standard Library, page 196.
2) Accelerated C++, page 137.
3) Accelerated C++, page 321.
Matthew
|
|
|
|
|
Sorry, the examples didn't print out right:
1) map<key, elem, op> m;
2) map<key, elem> m(op);
3) map<key, elem, op> m(op);
Matthew
|
|
|
|
|
how to make button control colorful .
|
|
|
|
|
MSDN Documentation states:
Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or BS_PUSHLIKE styles do not use the returned brush. Buttons with these styles are always drawn with the default system colors. Drawing push buttons requires several different brushes-face, highlight and shadow-but the WM_CTLCOLORBTN message allows only one brush to be returned. To provide a custom appearance for push buttons, use an owner-drawn button.
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
is this[^] color full enough
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
so far i am able to convert HWND to string but i am not able to find a way to convert string to HWND .
There is a way to convert hex string to int but not hex.
so either someone tell me int to hex conversion or direct string to hex.
Unmanaged in a .NET world
|
|
|
|
|
string sApple = "463A";
long lNum;
char* pE;
lNum = strtol(sApple.c_str(), &pE, 16);
printf("0x%X\n", lNum);
HWND hW = (HWND)lNum;
<b>Maxwell Chen</b>
|
|
|
|
|
Thanx very much , it really worked , thanx
Unmanaged in a .NET world
|
|
|
|
|
hi all,
I would like my dialog-based app to pop up a message box right after the dialog itself is shown on the screen... anyone knows how to do that?
If I put a message box in my dialog's OnInitDialog like this:
BOOL CTestDlg::OnInitDialog()<br />
{<br />
CDialog::OnInitDialog();<br />
......<br />
AfxMessageBox("hello"); <br />
return TRUE;
}
the message box pops up before the main dialog appears, but I want the message box to pop up AFTER the main dialog appears. I've tried handling WM_SHOWWINDOW message, i.e., put the AfxMessageBox in the dialog's OnShowWindow() function, but it was the same thing as putting the AfxMessageBox in OnInitDialog() -- the message box still pops up before the main dialog appears.
Thanks for your help in advance
|
|
|
|
|
The easist way is post a custom message to your dialog from the OnInitDialog function, that way OnInitDialog will close, and the dialog will be created before the message is handled. In the custom message handler you call AfxMessageBox.
#define WMU_POPUPMESSAGEBOX WM_APP;
...
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
...
ON_MESSAGE(WMU_POPUPMESSAGEBOX, OnPopupMessageBox)
END_MESSAGE_MAP()
...
BOOL CTestDlg::OnInitDialog()
{
...
PostMessage(WMU_POPUPMESSAGEBOX, 0, 0);
return TRUE;
}
HRESULT OnPopupMessageBox(WPARAM, LPARAM)
{
AfxMessageBox(_T("Hello"));
return 0;
}
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks dear Mr. Arends, It Worked!
|
|
|
|
|
Hey, i used the following technique in my program to solve a same problem.
when you recieve WM_INITDIALOG message, call ShowWindow(hDlg,SW_SHOW); //plese write the MFC equivalent urself;P)
After that, you can call MessageBox to do your stuff...
That's simpler solution.
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Hi ,
When i use the scrollbars the position of the window also changes.
Can i attach my code instead of pasting it?
Thanks and regards,
Salil.
CString szFilename("d:\\vc\\mfc\\2001.bmp");
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL,szFilename,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp;
bmp.Attach(hBmp);
CClientDC dc(this);
CDC bmDC;
bmDC.CreateCompatibleDC(&dc);
CBitmap *pOldbmp = bmDC.SelectObject(&bmp);
BITMAP bi;
bmp.GetBitmap(&bi);
dc.StretchBlt (0,0,len_in_pix,ht_in_pix,&bmDC,0,0,bi.bmWidth
,bi.bmHeight,SRCCOPY);
bmDC.SelectObject(pOldbmp);
CString szFilename1("d:\\vc\\mfc\\2002.bmp");
HBITMAP hBmp1 = (HBITMAP)::LoadImage(NULL,szFilename1,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp1;
bmp1.Attach(hBmp1);
CClientDC dc1(this);
CDC bmDC1;
bmDC1.CreateCompatibleDC(&dc1);
CBitmap *pOldbmp1 = bmDC1.SelectObject(&bmp1);
BITMAP bi1;
bmp1.GetBitmap(&bi1);
dc1.StretchBlt (0,br_in_pix,len_in_pix,ht_in_pix,&bmDC1,0,0,bi.bmWidth
,bi.bmHeight,SRCCOPY);
bmDC1.SelectObject(pOldbmp1);
CString szFilename2("d:\\vc\\mfc\\2003.bmp");
HBITMAP hBmp2 = (HBITMAP)::LoadImage(NULL,szFilename2,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp2;
bmp2.Attach(hBmp2);
CClientDC dc2(this);
CDC bmDC2;
bmDC2.CreateCompatibleDC(&dc2);
CBitmap *pOldbmp2 = bmDC2.SelectObject(&bmp2);
BITMAP bi2;
bmp2.GetBitmap(&bi2);
dc2.StretchBlt (0,br_in_pix+ht_in_pix,len_in_pix,br_in_pix,&bmDC2,0,0,bi.bmWidth
,bi.bmHeight,SRCCOPY);
bmDC2.SelectObject(pOldbmp2);
CString szFilename3("d:\\vc\\mfc\\2004.bmp");
HBITMAP hBmp3 = (HBITMAP)::LoadImage(NULL,szFilename3,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp3;
bmp3.Attach(hBmp3);
CClientDC dc3(this);
CDC bmDC3;
bmDC3.CreateCompatibleDC(&dc3);
CBitmap *pOldbmp3 = bmDC3.SelectObject(&bmp3);
BITMAP bi3;
bmp3.GetBitmap(&bi3);
dc3.StretchBlt (0,2*br_in_pix+ht_in_pix,len_in_pix,ht_in_pix,&bmDC3
,0,0,bi.bmWidth,bi.bmHeight,SRCCOPY);
bmDC3.SelectObject(pOldbmp3);
CString szFilename4("d:\\vc\\mfc\\2005.bmp");
HBITMAP hBmp4 = (HBITMAP)::LoadImage(NULL,szFilename4,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp4;
bmp4.Attach(hBmp4);
CClientDC dc4(this);
CDC bmDC4;
bmDC4.CreateCompatibleDC(&dc4);
CBitmap *pOldbmp4 = bmDC4.SelectObject(&bmp4);
BITMAP bi4;
bmp4.GetBitmap(&bi4);
dc4.StretchBlt (0,2*br_in_pix+2*ht_in_pix,len_in_pix,20,&bmDC4
,0,0,bi.bmWidth,20,SRCCOPY);
bmDC4.SelectObject(pOldbmp4);
void CAprsView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if(GetSafeHwnd() != NULL) {
SetScrollers();
}
}
void CAprsView::SetScrollers()
{
CRect image;
GetWindowRect(&image);
ScreenToClient(&image);
CRect view;
GetClientRect(&view);
//****************************************************************
// Vertical Scrollbar setting
//****************************************************************
SCROLLINFO info;
::ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info);
// Do not disable the scrollbar if the image is scrolled
// off the top; it must be vertically entirely
// scrolled on to disable the scrollbars
if(image.top == 0 && image.Height() < view.Height())
{ // no vert scrolling
info.nMin = 0;
info.nMax = 0;
info.fMask = SIF_RANGE;
} //no vert scrolling
else
{ // vert scrolling
info.nMin = 0;
info.nMax = image.Height();
// The code below fiddles the page size to keep
// the scrollbar from disappearing when the page size
// equals the scroll range, a feature of the built-in
// control
if(image.top < 0 && view.Height() >= image.Height())
{ // need more
info.nPage = image.Height() + image.top + 1;
} // need more
else
{ // just fine
info.nPage = view.Height();
} // just fine
info.fMask = SIF_RANGE | SIF_PAGE;
} // vert scrolling
SetScrollInfo(SB_VERT, &info);
//****************************************************************
// Horizontal Scrollbar setting
//****************************************************************
::ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info);
if(image.left == 0 && image.Width() < view.Width())
{ //no horz scrolling
info.nMin = 0;
info.nMax = 0;
info.fMask = SIF_RANGE;
} // no horz scrolling
else
{ // horz scrolling
info.nMin = 0;
info.nMax = image.Width(); // - view.Width();
if(image.top < 0 && view.Width() >= image.Width())
{ // need more
info.nPage = image.Width() + image.top + 1;
} // need more
else
{ // just fine
info.nPage = view.Width();
} // just fine
info.fMask = SIF_RANGE | SIF_PAGE;
} // horz scrolling
SetScrollInfo(SB_HORZ, &info);
}
void CAprsView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
void CAprsView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int newpos = GetScrollPos(SB_HORZ);
SCROLLINFO info;
::ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info);
info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;
GetScrollInfo(SB_HORZ, &info);
int low = info.nMin;
int high = info.nMax - info.nPage;
CRect view;
GetClientRect(&view);
CRect image;
GetWindowRect(&image);
ScreenToClient(&image);
switch(nSBCode)
{ /* nSBCode */
case SB_LINEUP:
newpos -= ::GetSystemMetrics(SM_CXVSCROLL);
if(newpos < low)
newpos = low;
break;
case SB_LINEDOWN:
newpos += ::GetSystemMetrics(SM_CXVSCROLL);
if(newpos > high)
newpos = high;
break;
case SB_PAGEUP:
newpos -= view.Height();
if(newpos < low)
newpos = low;
break;
case SB_PAGEDOWN:
newpos += view.Height();
if(newpos > high)
newpos = high;
break;
case SB_THUMBTRACK:
newpos = info.nTrackPos;
break;
case SB_THUMBPOSITION:
newpos = info.nTrackPos;
break;
} /* nSBCode */
SetScrollPos(SB_HORZ, newpos);
SetWindowPos(NULL, -newpos , image.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CAprsView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
SCROLLINFO info;
::ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info);
info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;
GetScrollInfo(SB_VERT, &info);
int low = info.nMin;
int high = info.nMax - info.nPage;
int newpos = info.nPos;
CRect view;
GetClientRect(&view);
CRect image;
GetWindowRect(&image);
ScreenToClient(&image);
switch(nSBCode)
{ /* nSBCode */
case SB_LINEUP:
newpos -= ::GetSystemMetrics(SM_CYHSCROLL);
if(newpos < low)
newpos = low;
break;
case SB_LINEDOWN:
newpos += ::GetSystemMetrics(SM_CYHSCROLL);
if(newpos > high)
newpos = high;
break;
case SB_PAGEUP:
newpos -= view.Height();
if(newpos < low)
newpos = low;
break;
case SB_PAGEDOWN:
newpos += view.Height();
if(newpos > high)
newpos = high;
break;
case SB_THUMBTRACK:
newpos = info.nTrackPos;
break;
case SB_THUMBPOSITION:
newpos = info.nTrackPos;
break;
} /* nSBCode */
SetScrollPos(SB_VERT, newpos);
SetWindowPos(NULL,image.left,-newpos,0, 0, SWP_NOSIZE | SWP_NOZORDER);
CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
}
|
|
|
|
|
I have a form based application window and i need to make its size fixed.How do i do it.
|
|
|
|
|
I'm assuming you are using MFC and your app is using a CFormView derived class and not a CDialog class.
Add a handler for the WM_GETMINMAXINFO in your CMainFrame class.
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) <br />
{<br />
lpMMI->ptMaxSize.x = 800;<br />
lpMMI->ptMaxSize.y = 600;<br />
lpMMI->ptMaxTrackSize.x = 800;<br />
lpMMI->ptMaxTrackSize.y = 600;<br />
lpMMI->ptMinTrackSize.x = 800;<br />
lpMMI->ptMinTrackSize.y = 600;<br />
CFrameWnd::OnGetMinMaxInfo(lpMMI);<br />
}
Michael
|
|
|
|
|
HI Friends,
I would like to know how to hide the row in list ctrl. I tried the CListCtrl::SetItemState(). I have used all nState, nMask parameter which arespecified in MSDN.
It was given in MSDN that to hide the row in List Ctrl we need to use the CListCtrl::SetItemState(...). BUt unfortunately I am not able to figure out how to use it. This is very urgent. Please help me!!!
Thanks in Advance.
bbye
|
|
|
|
|
Hiding rows is not possible in list controls.
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
Hi,
But it is given in MSDN that it is possible by using CListCtr::SetItemState(...). U please read MSDN help about the CListCtrl.
|
|
|
|
|
SetItemState does not change the fact whether the row is 'shown' or not. It only changes the state values for the row, which are the following, as quoted from the April 2004 MSDN:
- LVIS_CUT: The item is marked for a cut-and-paste operation.
- LVIS_DROPHILITED: The item is highlighted as a drag-and-drop target.
- LVIS_FOCUSED: The item has the focus, so it is surrounded by a standard focus rectangle. Although more than one item may be selected, only one item can have the focus.
- LVIS_SELECTED: The item is selected. The appearance of a selected item depends on whether it has the focus and also on the system colors used for selection. Items will only show as selected if the list-view control has focus or the LVS_SHOWSELALWAYS style is used.
If you need to 'hide' a row, you must delete the corresponding item.
Software Zen: delete this;
|
|
|
|
|
Hi all,
Is it possible to MONITORING system activity such as file copying.?
I want to know what happens when a file is copied from one place to another place.How windows Copy or Cut a file from one place to another place.is it possible to HOOK this process.?
Thanks.
|
|
|
|
|
I think there is something called ICopyHook interface if you implement the interface and register the component the right way you can monitor the copying process.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
ICopyHook is only for folders not for files
for files one will have to write a system driver
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|