|
Seems like somehow you have corrupted the stack. Is there any loop in one of your handlers that might be going out of bounds?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
To be honest with you, I have no idea where to even start debugging it.
My best guess right now is it has something to do with maybe the property sheet because this problem occurs after the user opens options.
Kuphryn
|
|
|
|
|
Okay. I have found the problem.
The problem has to do with the way I was determining the state of an item in a CListCtrl. I had to change the algorithm. Now the program no longer crashes.
MFC does some really weird stuff in the background. Be careful or you might end up with many problems.
Kuphryn
|
|
|
|
|
I have a operation which writes a string to a ListBox. Followed by anther function. The problem is the other function starts before the string is displayed in the list box. i:e
plistbox.AddString("xyx"); // writes string to list box
if(!(my_function()))
{
// fail
}
else
{
// pass
}
How do I make sure the ListBox has been updated before the next function is called.
Any help would be appreciated
Thanks
The problem is the next process seems to start before the string is displayed in the ListBox.
Desmond Mardle
|
|
|
|
|
Your problem has nothing to do with overlapping processes or anything like that. Try calling plistBox.RedrawWindow() after adding the string (and before calling my_function .)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your help. Problem solved:
Desmond Mardle
|
|
|
|
|
If I understand the problem correctly try:
UpdateData(FALSE);
Between writing the string and calling the function.
Mike Mullikin - People demand freedom of speech as a compensation for the freedom of thought which they seldom use.
Soren Kierkegaard
|
|
|
|
|
Hello,
In this type of application where the left pane is a treeview and the right pane is a listview, how do you keep the input focus on the left pane?
Example, I need to be able to perform needed operations on the right pane while the item in the tree is selected.
Is this possible?
Thanks,
Frank
|
|
|
|
|
I'm trying to get a handle (no pun) on threads.
I've got a function that calls two functions one after the other then returns. I'd like to multithread it because the functions lock up the UI in my App.
So...Question #1: When multithreading a function are the actions performed in the functions called from that function also performed in the new thread?
Question #2: Whats the easiest way to implement something like this?
Frank
|
|
|
|
|
#1. Yes. The whole function is executed in the new thread, which exits when the function exits. For instance:
DWORD WINAPI MyThread(LPVOID arg){
function1();
function2();
return 0;
}
DWORD dwThreadId;
HANDLE hThread=CreateThread(
NULL,
0,
MyThread,
NULL,
0,
&dwThreadId
);
#2: The code above just answer this. For production level code you'll need some more stuff (to control when the thread exists, for instance) but this piece of code should get you started.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Great! Thanks for the info.
Frank
|
|
|
|
|
I never want any scrollbars to show up in my MDI. Any way? I tried tthe cs but it want realy responsive. MAybe I didnt try enough? ?
Thanks,
ns
|
|
|
|
|
I am going to have to abandon my oh-so-cool MDI approach since I cant get around a movewindow issue which I'll describe in a bit. SO I am thinking SDi. But I need two views. Can an SDI handle two views?
The MDI dilemma:
Four edit boxes are supposed to hug the right edge always, even on resize. SO onsize I did movewindow setting the top y value to 10, 50, etc....
Fine. But if I scroll without resize, and some are off the visible part, then resize, they immediately pop back at 10, 50 etc from the top edge, leaving a big blank space above in the scrolled off portion. No matter whats the visible screen area, they alwyas show up at 10,50 etc from the top, on resize, leaving gaps where they should have been....
Any solution to this? I do like the MDI otherwise. LOts of hard work ahead if SDi wont do two views....
Thanks,
ns
|
|
|
|
|
Not sure exactly haw you are doing your scrolling, but when you do a resize, it seems to me you are not taking the scrolled distance into account when you calculate the new position of the edit controls, you are just simply placing them X distance from the top of your client area.
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
The scrollbars come up automatically since my CFormView is too big (by design) for the Client window.
I tried putting the repositioning in the OnScroll event as well, but now its as if theres no scrollability for those controls!!! So my fix is not right. Can I bother you for more hints on how to calculate how much I scrolled and take that into account? I cant quite see what I am to do here. I'd really really appreciate your help,
Thanks,
ns
|
|
|
|
|
My guess is that you are doing something like :
void CMyFormView::OnSize(UINT nType, int cx, int cy)
{
m_MyEditCtrl.MoveWindow(cx - EditCtrlWidth, 50, EditCtrlWidth, EditCtrlHeight);
... in order to place the edit control at the right edge, 50 pixels from the top.
What you have to do is call GetScrollPosition() to figure the scrolling into the calculation
void CMyFormView::OnSize(UINT nType, int cx, int cy)
{
int HScrollDistance = GetScrollPosition().y;
m_MyEditCtrl.MoveWindow(cx - EditCtrlWidth, 50 - HScrollDistance, EditCtrlWidth, EditCtrlHeight);
...
HTH
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
I am totally overwhelmed. I have been so stressed out over this, and was going to do a dialog based app instead of the cool mDI, and this was really distressing. I've tried your solution on one of my boxes and its behaving wonderfully. I wont breathe until I check it out on the whole UI but I am most hopeful!
You have saved my life literally! I am very grateful.
I had looked around for some function like this but it wasnt in the class wizard or in the members of the class CView either...where is it inherited from?
ANother associated question. This has been happening with my editboxes so I have to do something like(to prevent a debug assert). If I dont put your statement inside the if, it debug asserts. If I didnt have an editbox I was checking for, how would I have handled the assert? Which objects GetSafeHWnd would I test? I dont know if this is clear but its something I'd like to know about, if you have any ideas why....
if( NULL != m_editright.GetSafeHwnd() )
{
int VScrollDistance = GetScrollPosition().y;
m_editright.MoveWindow(cx - 200, 50 - VScrollDistance, 200, 200);
// m_editright.MoveWindow(cx-200,360,200, cy-60);
}
Thank you,
ns
|
|
|
|
|
ns wrote:
where is it inherited from?
CObject
-CCmdTarget
--CWnd
---CView
----CScrollView
-----CFormView
GetScrollPosition is a member of CScrollView
ns wrote:
ANother associated question
I should have remembered this, but it has been a while since i did something like this.
OnSize is called when the form is first created, before any of it's child controls are created. So you are right, you will get ASSERT's if you try to access nonexistant child controls. You are handling the situation correctly.
HTH
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
Its the same with setwindowpos. I have a control I want to "attach " to the right edge of the CFormView in my MDI. I do this with movewindow in onSize, and set the y top as say 10 - some fixed value. This form is scrollable. Now when I scroll the control off the screen and resize, it immediately pops back into view - 10 pixels from the top edge, leaving a big blank space above it - the area that had been scrolled off. So it thinks its supposed to be at 10 pixels from the top, and repositions itself, leaving a blank gap above. I am deeply troubled by this. Help!!!
Thanks,
ns
|
|
|
|
|
Hey, I have a question regarding the windows message EM_SETCHARFORMAT. I am trying to use this and I am having a problem. I have a text editor and it allows the user to set the text to different fonts. This works but if, for example, there are 5 lines of text, each line has a different font, when I highlight all 5 lines and try to change the font, it only changes the font of the first selected line, not all 5 lines. Any idea what is causing this, the carriage return perhaps? How do I fix this so it will change the font for all the lines?
|
|
|
|
|
1.
How can I change font of a CFileDialog in MFC application and OPENFILENAME in Win32 Application ?
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
In MSDN, I found a samples: ChatSvr and Chatter. That is a network application using CSocket. But I don't know how to use CSocket in multithread. In ChatSvr, I want to throw each client connecting to server to a particular thread. It means server will manage each client ( and his socket) in 1 thread. How can I do that ?
I imagine the code for solving this problem may be like this:
void CServerDoc::ProcessPendingAccept()
{
CClientSocket* pSocket = new CClientSocket(this);
if (m_pSocket->Accept(*pSocket))
{
pSocket->Init();
m_connectionList.AddTail(pSocket);
//Add this line:
m_threadList.Add(....);
//or
AfxBeginThread(....);
}
else
delete pSocket;
}
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
I've created two regions with the CRgn class and the function CreatePolygonRgn. I then use the CombineRgn function to take the intesection of the two regions created with CreatePolygonRgn. I now need to turn the resulting region into a polygon.
I've been trying to use the GetRegionData function to return the points that make up the region. But I'm not having a success. The function keeps returning NULL for the RGNDATA pointer. Here is what I did:
RGNDATA* pRgnData;
x=aRgn.GetRegionData(NULL,1);
y=aRgn.GetRegionData(pRgnData,x);
pRgnData is still NULL.
What am I doing wrong?
|
|
|
|
|
YOU've got to allocate the buffer into which OS will put the region data. If you pass it your null pointer, it will tell you how space you should allocate for the buffer. The example above is passing an undefined pointer.
e.g.
DWORD x=aRgn.GetRegionData(NULL,1);
RGNDATA* pRgnData=(RGNDATA*)malloc(x);
DWORD y=aRgn.GetRegionData(pRgnData,x);
|
|
|
|
|
Thanks Scott. I'll try that.
Paul
|
|
|
|