|
Why can't you derive from CMultiDocTemplate ? If the MFC wizard does not give you the option (is this the problem?) you can always create a derived class manually. Later, substitute CMyMultiDocTemplate (or whatever) for all occurrences of CMultiDocTemplate in your code.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I ran into something similar recently. Notice that OpenDocumentFile return a pointer to the CDocument it just created. You can use it to notify the view.
CMyDoc *pDoc = m_pDocTemplate->OpenDocumentFile(NULL);
pDoc->SetValues(...);
pDoc->UpdateAllViews(NULL, WM_DONE_SOMETHING); In view code...
void CMyView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
if(lHint == WM_DONE_SOMETHING)
{
CMyDoc* pDoc = GetDocument();
.
.
}
} Hope this helps.
P.S. Look at CDocument::UpdateAllViews. There is a third CObject parameter you can use...
Jonathan Craig
www.mcw-tech.com
|
|
|
|
|
I have a simple SDI app with a CFormView-based view. However, this gives a border around the app that makes the menu and status bar appear 'above' the actual view itself.
Unfortunately my client would rather the all appeared on the same level, I guess like a dialog-based app.
Any ideas how I can do this?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Please see this thread where Paolo Messina struggles his way to the solution.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Joaquín M López Muñoz wrote:
Please see this thread where Paolo Messina struggles his way to the solution
Wow! Do you actually book mark all interesting threads?
Nish
[Signature temporarily down]
|
|
|
|
|
Whenever I found such a gadget and use it in one of my programs, I add a little comment with the place I extracted it from for later reference. It is easier to remember where I used such and such trick rather than the URL itself.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
o.k. so say i have data like:
DataString = "2432382ab" or "238233923829cd" or "23882323rq"
and I want to extract the two rightmost elements (say the letters above) in VB I would do:
theLeft = right(DataString,2)
in C++ ?
string theLeft
theLeft = DataString.substr(-2,2);
someone told me i could do this, but I can't get it to work . . .
thanks if you can help!
tim
---------------------------------------
Tim Booher
|
|
|
|
|
CString s="hello world";
CString s2=s.Right(2);
Nish
[Signature temporarily down]
|
|
|
|
|
If you're using std::string s the way to go is DataString.substr(DataString.size()-2) .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
yeah -- that is exactly what i needed . . . thanks . .. tim
---------------------------------------
Tim Booher
|
|
|
|
|
Some time ago I wrote the code for own control delived from CWnd. The class is using the code for drawing color edge (for redrawing standart windows client edge). This code is correct but it blink. :
void CWnd::OnNCPaint(){
CWnd::OnNCPaint(); // this line I have only for drawing scrollbars because i dont know how to draw it myself. If you call this function, Windows will draw standart client edge and the control (nonclient area) blink !!
CWindowDC dc(this);
CRect rect;
GetWindowRect(&rect);
dc.Draw3dRect(0,0,rect.Width(),rect.Height(),RGB(255,0,0),RGB(0,0,255));
}
I showed in MSDN but i dont find anything
if you call this :
CScrollBar * scrollbar = GetScrollBarCtrl(SB_VERT);
scrollbar->Invalidate();
it will be assert because scrollbar is not valid window (ASSERT(::IsWindow(m_hWnd)))
Thanks very much !!!!!!!
Wiizi
|
|
|
|
|
I haven't worked out this idea, but maybe it is of some help. In your preliminary solution, instead of calling CWnd::OnNCPaint issue a call to the default window proc like this:
DefWindowProc(WM_NCPAINT,(WPARAM)hRgn,0); hRgn is a region that indicates the clipping area for doing nc painting. Maybe you can create a rectangular region that excludes the border to avoid the flickering.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Good morning everyone. Here's today question.
I have an SDI with the view spilt into 3 columns using CSplitterWnd. I'm trying to set the width of the 1st and 3rd columns to specific widths. Is there a way to explicitly set the width of the 3rd column to a fixed width? I've tried to set width of the 3rd column using
m_wndSplit.SetColumnInfo(2, 3RD_COL_WIDTH, 3RD_COL_WIDTH)
but it just sets the width to whatever is leftover from columns 1 and 2.
Do I have to just get the desired widths of 1 and 3 and set 2 to the remainding width? If so, could someone send me a snippit on the best way to do this. I'm still getting used to proper windows size management.
Thanks in advance.
Marcus
Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope
-- Daniel Burnham
|
|
|
|
|
I have a Word document.I want to input this document to a
database.Generally,i will create a table in a database,then input a
column ,then input next column. In order to save my time,now i want to
input the whole Word document by a program.
please tell me some English information about this.Or tell me web
sites.Thank you!
huang chun shen
|
|
|
|
|
I reply you once,did you see that?
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
|
|
|
|
|
Some time ago I wrote the code for own control delived from CWnd. The class is using the code for drawing color edge (for redrawing standart windows client edge). This code is correct but it blink. :
void CWnd::OnNCPaint(){
CWnd::OnNCPaint(); // this line I have only for drawing scrollbars because i dont know how to draw it myself. If you call this function, Windows will draw standart client edge and the control (nonclient area) blink !!
CWindowDC dc(this);
CRect rect;
GetWindowRect(&rect);
dc.Draw3dRect(0,0,rect.Width(),rect.Height(),RGB(255,0,0),RGB(0,0,255));
}
I showed in MSDN but i dont find anything
if you call this :
CScrollBar * scrollbar = GetScrollBarCtrl(SB_VERT);
scrollbar->Invalidate();
it will be assert because scrollbar is not valid window (ASSERT(::IsWindow(m_hWnd)))
Thanks very much !!!!!!!
Wiizi
|
|
|
|
|
|
I used the rand() function the other day.
From the MSDN it says:
The rand function returns a pseudorandom integer in the range 0 to RAND_MAX. Use the srand function to seed the pseudorandom-number generator before calling rand.
1. Seed the generator with srand()
2. Generate a random number with rand()
3. Divide the generated number by RAND_MAX.
4. Multiply the result 9 and add 1
This will give you a number between 1 and 10
I think this is right.
Marcus
Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope
-- Daniel Burnham
|
|
|
|
|
Well, as you already know, rand returns a randoum bumber between 0 and RAND_MAX . Usually it is more useful to have a random double uniformly distributed between 0 and 1, by evaluating (double)rand()/RAND_MAX . From here to a random integer number between 1 and 10 it is just simple arithmetic. Caveat: take into account the small (but actual) probability that (double)rand()/RAND_MAX yields exactly 1.0. In these cases the standard trick is to rerun the numer generation.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I find the % operator the easiest way to generate random numbers < RAND_MAX.
rand()%10 gives a number between 0 and 9, I need only add 1 to get a range of 1-10, or add 11 if I want a range of 11-20, etc.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
ok,...
so my code will look like:
rand()%10+1;
and how do i call that number up to see what it is? like:
if (the,rand,num == 1)
{
cout << "hello";
}
what is < RAND_MAX supposed to do?
RAND_MAX = 11;
rand()%10+1;
is that right, it doensnt feel right...
Thanks
~SilverShalkin
Questions are things that teach us well.
|
|
|
|
|
if (rand()%10)==1)
will do fine if you just want a 1 in 10 chance.
RAND_MAX is set in a #define, that is why it is all caps. It is the maximum value that rand() will return. If you don't use it in your calculations, i.e.
rand() * 10 / RAND_MAX
then it has no effect on the calculation at hand - it's not a magic constant, it's just a variable that the SDK sets to equal the top value that rand() can return.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Ok guys... I´m not much experienced with CSocket class... so here goes my question:
I´m creating a Windows NT service that open up a socket in a specific port and keep listening that port until someone connects to it. I´ve created a CListeningSock class, derived from CSocket, that has an override to the OnAccept virtual function. I created the socket, set it up to listening state and tried to activate my client software. The client socket was able to connect but the server socket didn´t received the OnAccept message (the virtual function was not called). I´ve created a Log function so that when the Services receives the OnAccept, an entry in the log file is created. The fact is that this entry was never written to the log file. The strangest thing is that if I use the same CListeningSock class in a "Dialog Based" project, instead of my nt service, the got damn class works and received the OnAccept ! Has anyone ever passed throught this ? Does CSocket needs a window to work !?!?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
|
|
|
|
|
Mauricio,
First of all I think it's not a good idea to use MFC in an NT service. I didnt think so till two days ago, when in a newsgroup discussion I had with Joseph Newcomer, he told me, why I should avoid using MFC in services.
Second I think OnAccept requires a valid HWND. I am not at all sure about this. *I might be absolutely wrong*.
Thanks
Nish
[Signature temporarily down]
|
|
|
|