|
|
OK,
Last question today. I am using the CDynViewDocTemplate class from the MSJ, where the doc template is supposed to swap views in a frame at run time for the same document. I have no problems running the sample, but run into trouble when I try and use this in my app. I am getting a debug assertion when the ReplaceView method of the doc template is called, something about don't paint the view until after you have called SetScrollInfo or something or other with CScrollView. I noticed the views in the sample from this MSJ artical were CView derived, not CScrollView derived. Anybody had any success with something similar? The initial view comes up fine, but swapping them out seems to be a problem.
Thanks,
Aaron
|
|
|
|
|
I don't know what's your sample article but this is a good sample for this purpose.You can use it for all kind of view.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
How can I load bitmap, draw circle inside it and then select it to CStatic object?
This code doesn't work, anyone know why?
Some problem with SelectObject()!?!
// IN: CStatic m_cDisplay;
if ((hBitmap = ::LoadBitmap(theApp.m_hInstance, MAKEINTRESOURCE(IDB_DISPLAY))) == NULL) return false;
HDC hWinDC = ::GetDC(m_hWnd);
if (hWinDC == NULL) return false;
if ((hDisplayDC = ::CreateCompatibleDC(hWinDC)) == NULL)
{
::ReleaseDC(m_hWnd, hWinDC);
return false;
}
SelectObject(hDisplayDC, hBitmap);
// Call draw circle
DrawCircle(&hDisplayDC);
m_cDisplay.ModifyStyle(0, SS_BITMAP, 0);
m_cDisplay.SetBitmap(hBitmap);
::ReleaseDC(m_hWnd, hWinDC);
return true;
|
|
|
|
|
What error is SelectObject returning?
One thing that I think may be a problem is the fact that you are trying to set the bitmap into the static control while it is still selected into the MemDC.
Try releasing the MemDC before you call SetBitmap.
<br />
DrawCircle(&hDisplayDC);<br />
<br />
m_cDisplay.ModifyStyle(0, SS_BITMAP, 0);<br />
<br />
<br />
::ReleaseDC(m_hWnd, hWinDC);<br />
<br />
m_cDisplay.SetBitmap(hBitmap);<br />
<br />
return true;<br />
This is just a guess, tell me what happens.
|
|
|
|
|
It doesn't work, but I've found other solution.
Thanks for trying.
|
|
|
|
|
What was the solution that you found, I am curious to know the answer.
|
|
|
|
|
Hi Again,
I need to send a command message to my app. I have a class which handles some command message through WM_COMMAND entries, but I need to be able to invoke these handlers programmatically.
I was thinking that this probably involves calling SendMessage with WM_COMMAND and the ID of the command, let's say for example ID_EDIT_COPY. Does this sound about right? Which window, the main frame window, and let it percolate downwards from there?
Thanks,
Aaron
|
|
|
|
|
AfxGetMainWnd()->SendMessage( WM_COMMAND, ID_EDIT_COPY );
That sends the message to the main frame, which should then do the MFC routing stuff. (My MFC's a bit rusty, I think sending to the main frame will do the trick.)
--Mike--
Fetchez la vache!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Michael Dunn wrote:
That sends the message to the main frame, which should then do the MFC routing stuff. (My MFC's a bit rusty, I think sending to the main frame will do the trick.)
I should think that will work. It is basically handled by main frame anyway as the menu is owned by the main frame window. That's why if we have a menu item handler in both the view and the main frame, the handler in the frame window class gets called and not the one in the view class.
Nish [not logged in today]
|
|
|
|
|
i have a file with the following:
score1 300
score2 400
score3 500
if i need to change the 400 in score2 to 50, how can I delete the whole 400 so it says:
score2 50
as opposed to:
score2 500
-Raffi
The truth about C++
|
|
|
|
|
Perhaps you should define a struct. Then you actually read or write a struct directly. If you want to edit one record [where each record is a struct], delete the record and add the new record which is a modification on the deleted record.
Nish
|
|
|
|
|
I know that you can use LoadCursor(NULL, IDC_WAIT) to load the standard hourglass cursor. The help that came with VC6 shows several other standard cursor IDs (such as a hand, a slashed circle, resizing arrows, etc) but I don't see one to show a cursor for dropping (such as moving a file to Explorer) -- an arrow with a little plus-sign.
Does anyone know an ID for that? Is there one, or do I have to create my own cursor image and load that? It seems like this one would be standard, but I don't see an ID for it.
Thanks in advance.
|
|
|
|
|
If you use OLE it will display those cursors for you (I think). Otherwise you can find them in ole32.dll. You can either extract the cursors or you can...
HMODULE hDll = LoadLibrary(TEXT("ole32.dll"));
HCURSOR hCursor = LoadCursor(hDll, id); The resource IDs are the following:
#define IDC_DRAG_CANNOT 1
#define IDC_DRAG_MOVE 2
#define IDC_DRAG_COPY 3
#define IDC_DRAG_LINK 4
|
|
|
|
|
Hi,
I've got another Doc/View qustion for the experts in MFC. I've got an app with a single document, and multiples views (sort of modeled after the MFC CHKBOOK sample, ie there are multiple doc templates registerd in the InitApplication method). Anyway, I've got a navigation control (a tree) in a dialogbar. Some of the nodes of this tree are associated with different view classes. The idea is that the user double clicks on a tree node to bring up a certain screen.
So, I would like to know how to iterate though all of the open views (looking for a specific type of view). If it is open, maximize it. If not, open that type of view in a window, then maximize it.
Where should I start?
Thanks
Aaron
|
|
|
|
|
Use CDocument::GetFirstViewPosition() and GetNextView() to iterate through the open views. Something like this:
POSITION pos = AfxGetMainWnd()->GetActiveDocument()->GetFirstViewPosition();
while ( NULL != pos )
{
CView* pView = AfxGetMainWnd()->GetActiveDocument()->GetNextView(pos);
if ( pView->IsKindOf ( RUNTIME_CLASS(CTheViewYoureLookingFor) ))
{
CFrameWnd* pFrame = pView->GetParentFrame();
pFrame->ShowWindow ( SW_SHOWMAXIMIZED );
break;
}
}
--Mike--
Fetchez la vache!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
I have a rectangle in my view,I want this rectangle to move,so I use SetTimer
to repaint the view for every 50 milliseconds,so it moves,but there is a bad thing here,
it just flickering Does anybody know any better way for moving objects or get rid of this flickering.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
|
I'll try it
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Nish,I can use GDI too,but I have to problem.
First,Can you tell me how can I fill rectangle .
Second:I have to draw it out of OnPaint or OnDraw cause I want to only update my rectangle,when I put this code out of OnPaint or OnDraw nothing appear in the view,what is wrong with that?
CPaintDC dc(this);
dc.Rectangle(56,45,30,10);
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Mazdak wrote:
First,Can you tell me how can I fill rectangle .
FillSolidRect, or ExtFloodFill if the rect is already there and you don't know it's bounds.
Mazdak wrote:
Second:I have to draw it out of OnPaint or OnDraw cause I want to only update my rectangle,when I put this code out of OnPaint or OnDraw nothing appear in the view,what is wrong with that?
CPaintDC dc(this);
dc.Rectangle(56,45,30,10);
That draws the outline of a rectangle, but it takes two sets of co-ordinates, not a left, top, width, height. Your second set of co-ordinates needs to be bigger than your first.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
Hello.
I am very familiar with C++ STL including the containers string and stringstream. When I learned of CString and other MFC data structure and mutator when I began learning MFC from Prosise's book (chapter 6).
I am learning MFC so that I can design and implement Windows 32bit programming using C++. Ultimate, as far as textchar data is concerned, is it perferrable to use CString over C++ STL (string, vector, list, etc.)? Is it possible to have view draw character from a string object instead of a CString object?
Lastly, does the default implementation for serialize work for C++ STL (string, vecto, list, etc.)? Does the STL container have to transfer data to a CString object first?
One last issue involving NULL. Microsoft seems to like using NULL over '0', which Deitel & Deitel recommend (I highly recommend their C++ How to Program). I do not use NULL term at all in my programs. I use '0'. When using core C++ program I have been working on into MFC, is it a necessity to change from '0' to NULL, bool to BOOL, true to TRUE, etc. for *all* code (even non MFC)?
Thanks,
Kuphryn
|
|
|
|
|
kuphryn wrote:
is it perferrable to use CString over C++ STL (string, vector, list, etc.)
That depends on the rest of the application. If the only part of MFC you're using is going to be CString, then its a lot of extra ovehead to carry.
kuphryn wrote:
Is it possible to have view draw character from a string object instead of a CString object?
Yes
kuphryn wrote:
Does the STL container have to transfer data to a CString object first?
No, just the oppsoite. If you're using the stl implementation that ships with VC then there is an overloaded << operator that converts the string to a LPCSTR. If you're like me and using a different STL implementation, then you'll need to write your own or manually cast the CString to a LPCSTR
kuphryn wrote:
is it a necessity to change from '0' to NULL, bool to BOOL, true to TRUE
from 0 to NULL - no, but bool and BOOL are different data types. They both mena the same, but a BOOL is just a typedef for an unsigned char (I think)
The opinions expressed in this post are the sole property of the writer and therefore are not guaranteed to contain any accurate statements, nor are they guaranteed to be worth the time you spent reading it.
|
|
|
|
|
David Fedolfi wrote:
They both mena the same, but a BOOL is just a typedef for an unsigned char (I think)
A BOOL is 4 bytes (in Win32 at least, dunno about Win64), while bool is 1 byte.
--Mike--
Fetchez la vache!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
|