|
I want to write characters to a CScrollView window one character at a time, much like CEditView. I've seen the MSDN docs on CDC and text related functions, but they work on entire strings. Given the x/y position and the font, how to display just one character? Thanks
|
|
|
|
|
If all you want to do is display text, why not just use a CEditView?
Software Zen: delete this;
|
|
|
|
|
How do I detect if a child control is inside the clipping area of current device context?
I have a ownerdraw listbox with two transparent buttons as child controls. In my listbox DrawItem() handler I need to manually trigger a child controls update in some case. So I like to test if a child window area is inside the clipping area of my pDC.
thanks for some help!
|
|
|
|
|
You can use this code in order to get the current clipping rgn that has been initialized from ::BeginPaint:
HRGN hRgn = ::CreateRectRgn(0,0,0,0);
::GetRandomRgn(hdc, hRgn, SYSRGN);
Then you will need to create a rgn from your child window and you can do an intersection test to determine if your child needs to be repainted. At that point you can force a repaint of your child window with a call to ::RedrawWindow with the interected region.
I have written two articles that may help you, the first is about device contexts and clipping regions and the other is a general article about regions.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
thanks, the article helps a lot for my understanding!
I feel good to find a solution for my problem.
|
|
|
|
|
Paul Watt wrote:
Then you will need to create a rgn from your child window and you can do an intersection test to determine if your child needs to be repainted. At that point you can force a repaint of your child window with a call to ::RedrawWindow with the interected region.
after playing with some ideas... I use this code now:
BOOL IsClientVisible(CDC* pParentDC, CWnd* pClientWnd)
{
ASSERT(pParentDC);
ASSERT(pClientWnd);
CRect rectClient;
pClientWnd->GetWindowRect(rectClient);
ScreenToClient(&rectClient);
return pParentDC->RectVisible(rectClient);
}
|
|
|
|
|
I want to create a Modal Dialog and be in control of it's position in the app.
Or even be able to dynamically change it's position.
Is this posible?
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
You can do that in two ways, the easy way is to have your dialog call your app and allow your app to determine if it needs to move your dialog.
The hard way may be a lot of work, but if this solution does not work, let me know and I will explain the other method.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
hi,
just wondering,
dlg.SetWindowPos()
can u jsut call SetWindowPos in response to event - say OnTimer - to adjust the dialog position?
i can imagine a situation in which u create a modal/modeless dlg and u wish the dialog to stay within the boundary of its view.
in this scenario, do u need to create your own event - for the dialog class? how can u implement this? how can u check that the child dialog is out of place (out-of-predefined boundary) and the fire an even and thru message map i suppose we can handle the situation appropriately??
thanks!
norm
|
|
|
|
|
I tried SetWindowPos() but it ASSERTS.
I was thinking that because I am calling DoModal(), I have lost control of the thing because MFC has taken over. Obviously, any attempts to adjust the position before DoModal() will ASSERT because the dialog window has yet to be created.
Any calls after DoModal() is pointless because MFC is in control.
I am trying a few different things right now.
IGeorgeI
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
hey there,
[QUOTE FROM CODE GURU]
u can do that by adding the virtual function pretranslatemessage
Eg:-
BOOL CUrDlg::PreTranslateMessage(MSG* pMsg)
{
if((pMsg->message == WM_KEYDOWN) )
{
if(GetFocus()->GetSafeHwnd() == GetDlgItem(IDC_UR_EDITCTL_ID)->GetSafeHwnd())
//necessary action
}
return CDialog::PreTranslateMessage(pMsg);
}
good luck =)
Norman
norm
|
|
|
|
|
Does anyone has an example on how to cancel a process? Like when the user press the Cancel button.
I tried _endthread() but I get 1st chance exception errors... What is the proper way?
Thanks!
|
|
|
|
|
I just used return; in the thread function and it seems to work... is this the proper way to do it?
|
|
|
|
|
_beginthread begins a thread of execution, not a process, second, it's evil, dump it and use _beginthreadex that have a appropriate Thread Information block(TIB) to properly clean the resources consumed by the thread.
Similarly the _endthread should not be used , use _endthreadex ... but it shouldn't use this either , the threads should exit for themselfs . You should create a event or binary semaphore (depending of what you want to achieve) and signal it to the thread that you want to cancel,then on the target thread that is expecting on a WaitforMultipleObjects(or similar), you catch the signed event(action) , clean up the resources , if you need to, and do a exit command(return ...) or exit simply by failling over the WaitFor ... loop ..
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
|
|
|
|
|
Hello,
I am trying to pull the text from a tool tip and put it into a CString.. The event fires but all I see in Debug mode is..
name =
name =
name =
Any suggestions?
void CMyTreeView::OnTvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTVGETINFOTIP pGetInfoTip = (LPNMTVGETINFOTIP)pNMHDR;
CString strTip = pGetInfoTip->pszText;
TRACE("name = %s\n",strTip);
*pResult = 0;
}
|
|
|
|
|
Never mind I figured it out
|
|
|
|
|
TVN - Tree view notification.
It is requesting the tool tip information from you. Not the other way around.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I was able to do this..
CString strTip = GetTreeCtrl().GetItemText(pGetInfoTip->hItem);
Rob
|
|
|
|
|
Still on the freakishly devilish CControlBars problem ...
I'm knee deep in MFC code right now, CDockContext , and I'd like to be able to trace CDockContext::CanDock, since it's called rather frequently, when moving a floating controlbar, I'd like to be able to find a way to trace it.
Same thing for CFrameWnd::CanDock ( winfram2.cpp ) ...
I'd like to ba able to tell the debugger, well, don't stop at this breakpoint, but just tell me that it should be triggered ...
Any Idea ?
Max.
|
|
|
|
|
|
I can't ( can I ? ) use TRACE in those files ( MFC's winfrm2.cpp and dockcont.cpp ), and I don't want to mess up MFC code ...
Max.
|
|
|
|
|
|
Hi guys
I'm developping an application that uses a database. And this database has to be updated from an internet adress.
The question is.
Could you propose me the way to do this automatically?
In other words There is a way to download a file from internet and substitute the actual database in the application directory?
Sorry if this questio looks silly to you, but I don't know how to do it, because I don't know how detect if the file download has benn completed.
Best regards
Doctor Pi
|
|
|
|
|
first if u using a db like sql server u cant just dnload files cos it doesnt work that way ... to detect if a file has dnloaded correctly u can put a checksum in it and verify that on receipt of the file ... to update the db (assuming u mean data) send a file in a format ur comfy with and use that to update the data from ... if ur changing the schema or stored procs etc use a file containing the sql queries to do the update
hope this helps
"traffic lights are for people who can't make their own decisions" biz stuff about me
|
|
|
|
|
Hello all,
I have a question concerning opening new windows. Currently, I have a MDI project that does not have doc/view support. It opens bitmaps. When I open a bitmap, it opens it to the main window. When I click File->New a new window appears. These features are great, yet I can't seem to combine them. I'd liek the bitmap to open into a new window. I can open bitmaps over and over and over again, but it always just replaces the current one. How can I get the bitmap to open into a new window?
Any ideas anyone? Like the code for File->New
CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
// create a new MDI child window
pFrame->CreateNewChild(
RUNTIME_CLASS(CChildFrame), IDR_NICKMITYPE, m_hMDIMenu, m_hMDIAccel);
How can I get this new window to open the bitmap into it, and not the background?
Thanks,
Nick Hughes
|
|
|
|