|
|
Respond to the WM_CTLCOLOR message, CTLCOLOR_DLG, and set the brush.
See CWnd::OnCtlColor in the DOCs
|
|
|
|
|
Hello all,
I've created new MFC AppWizard(exe) (SDI, but it doesn't matter),
my CView-class was inherited from CRichEditView class
(I turned on OLE support),
so, that's ok. It's compiled and worked.
Then I entered some character and tried to print them.
When I tried to do it on my Win2k server (service pack 2) I've got an extra blank page printed.
On NT 4.0 (Service Pack 6e) everything is OK.
I use MSVS 6.0 Service Pack 5.
So ?
Dmitry Belikov.
|
|
|
|
|
Hello!
I'm trying to use COleDateTime::ParseDateTime to parse a string according to a format that isn't in the locale. I use
SetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SSHORTDATE,myFormat); to set the date format and then ParseDateTime(myDateStr);
But ParseDateTime will return an error and the date isn't valid.
Anyone that know how to make this work!??
// Mike
|
|
|
|
|
The last param in the ParseDateTime method is used to specify a locale ID. Have you tried this?
|
|
|
|
|
Yes, I have tried the LDID param in ParseDateTime and it will change the date format according to the country standard. I have two problems with this:
First, I don't know all countries date format
Second, the dates that I have to parse are not likely to follow any known standard.
The people that have entered these dates (as text) have just made up a standard as they typed and different persons used different standards e.g.
Hmmm.... maybe I can add a new country?
Thanks for your reply!
// Mike
|
|
|
|
|
Dear all hi,
In windows explorer i have to open "Save as dailog box" when one double click on registered file say having extension ".abi". Plz tell me how can be it accomplished.
Regards
Abid
|
|
|
|
|
Hi,
Does anyone know if there is an API or some other means of determining what type of connection speed (e.g. 64K, 128K, T1 etc.) the computer has to the internet?
Thanks in advance
Neil
|
|
|
|
|
I want to get a pointer to a desired view through the document templates, then through the opened documents in each template and then through the opened views of each document until I get the view. It's a single document..
Oys
|
|
|
|
|
An Application can have one or more DocTemplates. Each of them can have one or more documents. And each Document can have one or more views. So actually if you want one particular view you will have to have three levels of loops.
Anyway here is a broad outline of how to get a view from Anywhere in the app.
[ccode]
CMyApp *pApp = AfxGetApp();
CDocTemplate* pDocTemplate;
CDocument* pDoc;
POSITION rPos1,rPos2,rPos3;
CView* pView;
rPos1 = pApp->GetFirstDocTemplatePosition();
while (rPos1)
{
pDocTemplate = GetNextDocTemplate(rPos1);
if (pDocTemplate)
{
rPos2 = pDocTemplate->GetFirstDocPosition();
while(rPos2)
{
pDoc = pDocTemplate->GetNextDoc(rPos2);
if (pDoc)
{
rPos3 = pDoc->GetFirstViewPosition();
while (rPos3)
{
pView = GetNextView(rPos3);
if (pView)
{
// check if this is the desired view and do
// your stuff
}
}
}
}
}
[/ccode]
Tell me if this helps.
|
|
|
|
|
Thanks for your help.
I think it worked to get the views. I have two views in my application and the while loop goes twice in "while(rPos3)".But what do I write in the if(pView == ???????) how do I know the identifier of my desired view. When I get the correct view how do I access the function setUsers() in this view. The view is named CTableview and I've derived it from CFormView.
Oys
|
|
|
|
|
try this:
#include "tableview.h"
...
if (pView->IsKindOf(RUNTIME_CLASS(CTableview))) {
CTableview* pTableview = (CTableview*)pView;
pTableview->setUsers();
}
...
CTableview would have to be at least DECLARE_DYNAMIC.
A note: I've used the ol'-fashion casting here ((CTableview*)pView) - I'm sure there's a lot of C++ gurus out there that want you to use static_cast<> or dynamic_cast<> or whatever instead - but I've never figured out which one to use so I stick with the old one.
good luck
Steen.
|
|
|
|
|
Regarding casting: there's a nice article on DevX about casting:
http://gethelp.devx.com/techtips/cpp_pro/10min/2001/july/10min0701.asp
happy hunting
Steen
|
|
|
|
|
It sounds like your design may be in error. In a propelry designed MFC app, there should be no need to call a function like SetUsers() externally from a view.
A view has two purposes:
1) It displays a document.
2) It handles UI commands.
The name of the fuction SetUsers() makes me think that your view is storing data.
|
|
|
|
|
Is there another way to solve the problem?
In CMainFrame I handle several menu choices. When a the user clicks in the menu I want the FlexGrid that's a member of CTableView to change. For example the number of colomns and the caption of each row should change when the user make different choices. SetUsers() is public and a member of CTableView, in this function I update the table when the user has pressed a choice called "manage users". I thought this would be the right way to go...call this function from CMainFrame where I handle onManageUsers().
Is the design in error?
Oys
|
|
|
|
|
If all the processing in OnManageUsers() can be done in CTableView then you should certainly let that class handle the menu choice (i.e. put the ON_COMMAND macro in CTableView's message map instead of putting it in CMainFrame's map). If some of the processing (such as updating the view) is done in the view, while other things is done in the frame you have a couple of options:
( in the code below I deliberately omit all semicolons at line ends - they will probably be translated into smileys
1) put OnManageUsers in CTableView, and use SendMessage/PostMessage to let CMainFrame do it's thing. You can make a private message (#define WM_MANAGEUSERS WM_APP + 1, for instance). In CTableView:
CTabelView::OnManageUsers()
{
... // do stuff
GetParentFrame()->SendMessage(WM_MANAGEUSERS, (WPARAM)something, (LPARAM)somethingelse)
... // do some more stuff
}
2) put OnManageUsers() in CMainFrame. Let it do whatever modifications is needed. The result of the modifications should somehow be available in the document class (CDocument derivate). At the end of OnManageUsers call the UpdateAllViews method of the document class. If you have more than one document open at a time this method is bad! UpdateAllViews will call all OnUpdate handlers in the view classes. In CTableView, let OnUpdate do the updating of the UI.
3) Let the document handle OnManageUsers() and let it notify the frame and any views.
Hope this helps
hope this helps
Steen.
|
|
|
|
|
It is possible to get a text underlined when you drag the mouse over the text?
OyS
|
|
|
|
|
Can you be more specific about what type of text you require to be highlighted. Is it on a button? Edit box? etc
Matt
------
Accept that some days you are the pigeon and some days the statue.
|
|
|
|
|
Thanks for your interest. It's just a static text. I have a single document with two views and in the left view I have several static texts. The static text are menu choices. When I drag the mouse over the text I want to underline it. When I click on the text I want it to get another color. I managed to get the the text to respond to click by OnLButtonDown() and OnMouseMove() to change cursor.
OyS
|
|
|
|
|
What are some good ones?
In particular I am looking for controls that would be useful for a touch screen application (pop-up virtual keyboards, etc.), also database aware controls using OLE DB.
|
|
|
|
|
Hi,
I need to read up on unicode, typically UTF-8
could someone please suggest some links or articles ?
thanx in advance
Noman
|
|
|
|
|
I'm adding controls to a dialog, and then I cannot add any more, is there a finite number of controls that I can add to a dialog?? How do I increase this number....??
TIA
Senior Test Engineer
GLI Australia
www.gli.com.au
|
|
|
|
|
IIRC you can only have 255 (or 256?) controls in a dialog resource. If you need more, you must create the controls at runtime.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
Is it possible to register multiple file extensions with an SDI application?
I tried doing the following, but this strange box pops up (new document) but if I pick any choice but the first, an error occurs. Should I create a different document class to handle each file extension type? Or is there an easier way?
AddDocTemplate(new CSingleDocTemplate(IDR_FILETYPE1,
RUNTIME_CLASS(CTest2Doc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CTest2View)));
AddDocTemplate(new CSingleDocTemplate(IDR_FILETYPE2,
RUNTIME_CLASS(CTest2Doc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CTest2View)));
IDR_FILETYPE1 is "sdi app\n\n1\nfiles (*.txt)\n.txt\npart 6-1\npart 7-1"
IDR_FILETYPE2 is "sdi app\n\n1\nfiles2 (*.doc)\n.wsf\npart 6-2\npart 7-2"
--
Peace,
Amit Jain
|
|
|
|
|
Check the Microsoft Knowledge Base ( Q198538 ).
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|