|
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é.
|
|
|
|
|
|
Hi! I am new in using MFC and i am creating a drawing program similar to windows paint the problem i have is that i don't know how to program a tool that will draw polygon shapes using the mouse, also i have difficulty in making a eraser and fill tool for my paint program ... need help!!!! thanks!!!
|
|
|
|
|
Check this
This article is the same as paint program
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
|
|
|
|
|
Are you the same guy who asked about an erase tool the other day and then didn't answer my questions when I tried to help ?
1/ A polygon tool is easy - build a vector of the points you select and pass the address of the first element into the CDC::FillPolygon method. My Doodle program does the same using GDI+. If you don't know what a vector is, I just did an article under STL, search for STL101.
2/ I don't get it - an eraser as you asked me before is just a pen that draws white all the time - do you need help with a pen tool ? You just need to keep track of the last spot you drew from and draw lines every time you use the mouse.
3/ A fill tool can be done using a range of recursinve algorithms and direct pixel access, but ExtFloodFill works just fine.
Also, what format does your image take ? Is it a CBitmap ? If so, you need to ditch it, you'll only be able to draw in the bit depth of your screen. You need a DIBSection wrapper, or to use GDI+ to be able to work on images with different bit depths. Either of these will also give you direct pixel access.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
Thanks for the help!
We need help with th epen tool... if you could elaborate more on keeping track of the last spot i draw from.
I'll reply to you back if i got it already...
|
|
|
|
|
Create a member CPoint, and every onMouseMove, draw a line from that point to the new mouse position, then store the new mouse position in the member variable. Free hand drawing can only occur to the degree the system notes each individual position the mouse moves over, so you don't lose any accuracy from doing it this way, and I can't see any other way of doing it.
If you want filled shapes you should store the positions in a vector, and call FillPolygon with the address of the first vector element on mouse up.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
Just wanted to say thanks for the help i got the tools working....
thanks again....
|
|
|
|
|
Hi,
Anybody have sample code about ATL based SPLASH dialog?
Best Regards,
Perumalla Koteswara Rao,
JUNO Online Dev. Pvt. Ltd.
Hyderabad, India
|
|
|
|
|
This code is off of the top of my head. I have done a few splash screens this way, I know there are other ways to accomplish this, but this has worked for me.
<br />
class CSplashDlg : public CDialogImpl<CSplashDlg><br />
{<br />
private:<br />
int m_CurTime;<br />
int m_DisplayTime;<br />
<br />
public:<br />
enum { IDD = IDD_ABOUTBOX, SPLASH_TIMER = 100 };<br />
<br />
BEGIN_MSG_MAP(CAboutDlg)<br />
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)<br />
COMMAND_ID_HANDLER(IDOK, OnCloseCmd)<br />
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)<br />
MESSAGE_HANDLER(WM_TIMER, OnTimer)<br />
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)<br />
END_MSG_MAP()<br />
<br />
LRESULT OnInitDialog(UINT , WPARAM , LPARAM , BOOL& )<br />
{<br />
CenterWindow(GetParent());<br />
<br />
m_CurTime = 0;<br />
m_DisplayTime = 6;
this->SetTimer(SPLASH_TIMER, 500, NULL);<br />
<br />
return TRUE;<br />
}<br />
<br />
LRESULT OnCloseCmd(WORD , WORD wID, HWND , BOOL& )<br />
{<br />
EndDialog(wID);<br />
return 0;<br />
}<br />
<br />
LRESULT OnTimer(UINT , WPARAM wParam, LPARAM , BOOL& )<br />
{<br />
if (SPLASH_TIMER == wParam)<br />
{<br />
++m_CurTime;<br />
<br />
if (m_CurTime > m_DisplayTime)<br />
{<br />
this->DestroyWindow();<br />
}<br />
}<br />
return TRUE;<br />
}<br />
<br />
LRESULT OnDestroy(UINT , WPARAM wParam, LPARAM , BOOL& )<br />
{<br />
this->KillTimer(SPLASH_TIMER);<br />
return TRUE;<br />
}<br />
};<br />
Like I said this is off the top of my head, so you may need to fix any compiler errors that I have made. There is probably a better way to destroy the timer that I have created.
Create this dialog with a modeless call with something like this:
<br />
CSplashDlg dlgSplash;<br />
dlgSplash.ShowWindow(SW_NORMAL);<br />
<br />
With the way that it is currently written, it will disappear after 3 seconds. You can change the m_DisplayTime value in order to lengthen or shorten the time that the dialog is displayed.
ONe more thing you may want to mess around with the window styles in order to make this dialog top most and whatever else.
|
|
|
|
|