|
followait wrote:
Is it like this:
if the file is larger than n bytes, it won't complete until n bytes is read, and if the are less than n bytes to read, it will complete as soon as the end of file is reached.
Yes, that sounds correct. The read request could also be subject to cancelation of pending asynchronous I/O operations if FILE_FLAG_OVERLAPPED.
Additional Info:
Inside I/O Completion Ports[^]
I/O Completion Ports[^]
ReadFile Function[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hi,
I am having problem with creating CTabCtrl. I derived my class MyCTabCtrl from CTabCtrl.
In the view I am trying to dynamicaly create the control of MyCTabCtrl but always fails.
MyCTabCtrl* tab;
tab = new MyCTabCtrl();
tab->Create(TCS_TABS|WS_VISIBLE|WS_CHILD,CRect(10,10,100,100),this,12345);
When I define tab as CTabCtrl it creates fine. The default constructor of my class calls the base CTabCtrl constructor
MyCTabCtrl::MyCTabCtrl():CTabCtrl()
{
}
Thank you for your help, Tomas
|
|
|
|
|
How does it fail? Create returns FALSE? Check GetLastError, what does it give you?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I can't call the GetLastError, because the Create function stops on
ASSERT(::IsWindow(m_hWND)||(m_pCtrlSite != NULL)) in BOOL CWnd::SetWindowPos. It is called from AfxCtxCreateWindowEx.
I can post here the definition of MyCTabCtrl, but I think it is ok.
Thanks, Tomas
|
|
|
|
|
Around asserts in MFC code they usually also leave comments for you to know what the problem might be, so check that...
Try one thing, add a message map to your MyCTabCtrl if you didn't yet.
class MyCTabCtrl: public CTabCtrl
{
...
DECLARE_MESSAGE_MAP()
...
};
...
BEGIN_MESSAGE_MAP(MyCTabCtrl, CTabCtrl)
END_MESSAGE_MAP()
...
Another thing, you don't need to explicitly call the superclass's default constructor in your own default constructor, it will be called for you "automatically".
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi,
the ASSERT failure is on line 318 in winocc.cpp file. It is in a CWnd::SetWindowPos and the problem is that m_hWnd is bad pointer.
Why I am doing all this is because of the problem with serialization. When I had member of MyCTabCtrl associated to the CTabCtrl create in the designer it worked fine till open new file. I thought I would solve this problem by having a pointer an create new instance on every OnInitialUpdate(). If there is another solution to this problem I don't mind which one would I use.
But I still don't understand what is wrong with my class. I used the name MyCTabCtrl instead of Am_AnalysisParameters_TabCtrl for simplifying.
class Am_AnalysisParameters_TabCtrl : public CTabCtrl
{
DECLARE_DYNAMIC(Am_AnalysisParameters_TabCtrl)
public:
Am_AnalysisParameters_TabCtrl();
virtual ~Am_AnalysisParameters_TabCtrl();
int viewsID[2];
CFormView *views[2];
void InitViews();
void ActivateView();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnSize(UINT nType, int cx, int cy);
};
implementation of the class
IMPLEMENT_DYNAMIC(Am_AnalysisParameters_TabCtrl, CTabCtrl)
Am_AnalysisParameters_TabCtrl::Am_AnalysisParameters_TabCtrl()
{
viewsID[0] = IDD_AM_ANALYSISPARAM_BUILDINGTAB_FORMVIEW;
viewsID[1] = IDD_AM_ANALYSISPARAM_ADVANCEDTAB_FORMVIEW;
views[0] = new Am_AnalysisParameters_BuildingTab_FormView();
views[1] = new Am_AnalysisParameters_AdvancedTab_FormView();
}
Am_AnalysisParameters_TabCtrl::~Am_AnalysisParameters_TabCtrl()
{
}
BEGIN_MESSAGE_MAP(Am_AnalysisParameters_TabCtrl, CTabCtrl)
ON_NOTIFY_REFLECT(TCN_SELCHANGE, &Am_AnalysisParameters_TabCtrl::OnTcnSelchange)
ON_WM_SIZE()
END_MESSAGE_MAP()
and in my view class
void Am_AnalysisParameters_FormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
CRect rect;
GetWindowRect(rect);
analysisParamTabCtrl = new Am_AnalysisParameters_TabCtrl;
analysisParamTabCtrl->Create(TCS_TABS|WS_VISIBLE|WS_CHILD,CRect(10,10,100,100),this,12345);
}
Tomas
|
|
|
|
|
This is a guess from me but, i see that you have an array of views in your tab control and that you have a handler for the WM_SIZE message. Do you try to position/resize these views when the tab control itself gets the WM_SIZE? When the control gets created, it will receive a WM_SIZE message, so could it be that in your handler you call the SetWindowPos method on your views but these views were not yet created?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
No, there shouldn't be any problem with WM_SIZE. I just resize the tabcontrol itself and the tab views have there own method to handle WM_SIZE.
SetWindowPos it is called everytime you create new control.
Any sugestion??
Tomas
|
|
|
|
|
I juse copy-pasted your class into a basic dialog based project, removed the message handlers (since you didn't provide the code for those) and tried it, there was no failing assert, no problem at all. I think without actually seeing your full code i am at this point unable to suggest anything.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi
I want to make a button with two tool tips
I,e when the mouse cursor over the left half of the button it displays different tooltip than when the mouse over the right half
As you can see in www.visualcsamples.blogspot.com
I made a button with a button with 2 hover states one on the left and one on the right
Now I,am interested in making a button with 2 tooltips
It works fine the button with 2 hover state
help me
Thanks
|
|
|
|
|
As you can see in the documentation of CToolTipCtrl::AddTool[^], you can specify it a rectangle in the lpRectTool parameter, so basicly i guess all you need to do is add your button twice to the tooltip specifying the left and then the right part of it. Something like this:
m_myToolTip.AddTool(&m_myButton, _T("left side of my cool button"), &left_side_rect, left_tool_id);
m_myToolTip.AddTool(&m_myButton, _T("right side of my cool button"), &right_side_rect, right_tool_id);
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
hi
how to get left_side_rect ?
thanks
|
|
|
|
|
RECT exampleRect = {50,50,100,100};
RECT leftRect, rightRect;
leftRect = exampleRect;
leftRect.right -= (exampleRect.right-exampleRect.left) / 2;
rightRect = exampleRect;
rightRect.left = leftRect.right;
|
|
|
|
|
CRect left_side_rect, right_side_rect;
m_myButton.GetClientRect(&left_side_rect);
right_side_rect = left_side_rect;
left_side_rect.right = right_side_rect.left = left_side_rect.right / 2;
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Yeah, pretty much - though the code won't work in all cases(fails in cases where rect.left != 0).
What if I had a rect that had rect.left=10 & rect.right=20 ?
Clearly, the middle of these points is 15. Your code will return 10.
|
|
|
|
|
If you check out the documentation of GetClientRect[^], you see it states:
The GetClientRect function retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0).
Since we are working with the client rect here i don't see the need to handle the non-zero left-top case.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Oops, of course it does. It seems that my habit of working in screen co-ords has bitten me on the bum this time.
sorry.
|
|
|
|
|
No problem, we all suffer from occupational hazard
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
what is right_tool_id and right_tool_id ?
|
|
|
|
|
Come on, read the documentation(s) of the tooltip control and the AddTool method. Anyways, those are numeric values you use to identify the tools you feed to the tooltip control. Make sure these are unique for every tool you add to the tooltip control. Basicly, when you give a whole button or list or edit field or any other control to the tooltip control you can later on easily refer to the right tooltip by using the window handle you gave to the tooltip control. So, for example, if you add your custom button to the tooltip control and later want to change the tooltip text you can tell the tooltip control to "hey, tooltip control, please change the tooltip for the window with this handle to blablabla". But if you specify multiple areas for the tooltip which are on the same control, you need to have a way to identify those too. So for example, you add the left and right rectangles to the tooltip control which are on the same button and later on you want to change the tooltip text of the left part, saying "change the tooltip text of the button with this handle" won't be enough for the tooltip control because since this button has multiple areas added, it can't know which area you meant. So you also give your areas an ID. For example, you add the left part of the button with ID 12 and the right part with ID 23, and then you can tell the tooltip to change the tip text of the tool with the ID 12. Get it?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
|
Step 1: Add this data member to your CTasheDlg class: CToolTipCtrl m_tooltip;
Step 2: Add this method to your CTasheDlg:
BOOL CTasheDlg::PreTranslateMessage(MSG *pMsg)
{
if (m_tooltip.m_hWnd) m_tooltip.RelayEvent(pMsg);
return __super::PreTranslateMessage(pMsg);
}
Step 3: Add this to the OnInitDialog of your CTasheDlg:
m_tooltip.Create(this);
CRect leftRect(button_rectangle), rightRect(button_rectangle);
leftRect.right = rightRect.left = leftRect.right / 2;
m_tooltip.AddTool(&m_double_tooltips_button, "Left side", &leftRect, 1);
m_tooltip.AddTool(&m_double_tooltips_button, "Right side", &rightRect, 2); right after the line m_double_tooltips_button.GetClientRect(button_rectangle) ;
I believe you got all the help you need to get this to work...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
|
Erm? What do you want to do? How did you try it?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|