|
How can I know when the app gets minimized?
There is no WM_ for that, or...
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
|
Try WM_SYSCOMMAND with WPARAM SC_MINIMIZE .
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you both!
I never looked at WM_SIZE that well...
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Hey, how can you make dc draw commands (like FillRect) in a dialog box? The Dialog is a child of the CDialog class. Thanks
Bob
|
|
|
|
|
Provide a handler for the WM_PAINT message.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
If you are just wanting to fill in the background, then you should handle the WM_ERASEBKGND message, as this still allows default handling of WM_PAINT, meaning that dialog controls will paint themselves properly.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Hi!,
I use ODBC in a database MFC project. In My project, I already have the CClinicView, CClinicDoc and CClinicSet that represent my clinic table. I would like to add another table into my project. How can I do this?
Thanks!
Everything's beautiful if you look at it long enough...
|
|
|
|
|
You mean Multiple recordsets in an app?
To get multiple recordsets, you must create the CDatabase object first. Then you can construct as many recordsets as you want, passing a CDatabase pointer as a parameter to the CRecordset constructor. You start by embedding a CDatabase object in the document in place of the CRecordset object. You also include a pointer to the primary recordset. Here are the document data members:
CClinicSet* m_pClinicSet;
CDatabase m_database;
In your overridden CDocument::OnNewDocument function, you construct the primary recordset on the heap, passing the address of the CDatabase object to the recordset constructor. Here's the code you insert:
if (m_pClinicSet == NULL) {
m_pClinicSet = new CClinicSet(&m_database);
CString strConnect = m_pClinicSet->GetDefaultConnect();
m_database.Open(NULL, FALSE, FALSE, strConnect, FALSE);
}
In the CRecordView::OnInitialUpdate add:
m_pSet = GetDocument()->m_pClinicSet;
if(m_pSet->IsOpen())
{
m_pSet->Close();
}
m_pSet->Open();
Now you create another Class derived from CRecordset and link it with the table you want. and in the View, suppose you will load a list with this table.
in this case called CSectionSet.
void CClinicView::LoadListbox()
{
CClinicDoc* pDoc = GetDocument();
CListBox* pLB = (CListBox*) GetDlgItem(IDC_SECTIONS);
CSectionSet sect(&pDoc->m_database); // db passed via constructor
sect.m_strFilter.Format(....whatever filter you want);
sect.Open();
pLB->ResetContent();
while (!sect.IsEOF()) {
////load the ListBox
}
// sect closed by CRecordset destructor
}
I hope it works for you..
regards from Argentina!!
Daniel Cespedes Daza
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
Thank you so much!!!
That will help a lot...
Regards
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Is there any way to purge the pending messages for a Window?
Davy
Blog for Software Testing, Bugs, Quality, Security and Stability - www.latedecember.com
News From Angus, Scotland - The Angus Blog My Personal Blog - Homepage.
|
|
|
|
|
you could call PeekMessage in a loop, passing PM_REMOVE to actuallyr remove them. This will, however, not supress WM_TIMER or WM_PAINT messages.
I don't know if "hiding away" window messages is such a good idea, though.
Italian is a beautiful language. amare means to love, and amara bitter.
sighist | Agile Programming | doxygen
|
|
|
|
|
Thanks might try it. A video window is getting some extra (user defined) stop messages for some reason. I've tried stopping them been sent but that breaks loads of things. Still the guy who knows the code should be back tomorrow
Davy
Blog for Software Testing, Bugs, Quality, Security and Stability - www.latedecember.com
News From Angus, Scotland - The Angus Blog My Personal Blog - Homepage.
|
|
|
|
|
In this case it would be better (if anything else fails) to inject your own WindowProc, and pass on only those message that are "sutable" to the original proc.
Italian is a beautiful language. amare means to love, and amara bitter.
sighist | Agile Programming | doxygen
|
|
|
|
|
I put in a handler for both functions. IF I step in, on hitting enter in my textbox, I find that if the pretranslate code is there (returning true after handling VK_RETURN and KDOWN ) the OnCommand doesnt get triggered. I am trying to figure out why but not getting the reason from MSDN. Is this behavior to be expected and if so why? I cant quite figure out what translate msg does that makes onCommnad not run.. In the onCommand I look at the wParam,lParam and IDOK)
Appreciate your help,
ns
|
|
|
|
|
>IF I step in, on hitting enter in my textbox
Are you sure that OnCommand had to be generated on this event? For examlpe, OnComand will be generate if you
click some button, but not if the button set focus
or lost using Tab key.
Pretranslate massege gets ALL messages. And
if you do all right WM_COMMAND will be prosecute or
not, how you want.
================================
Useful links
|
|
|
|
|
I see in my debugging that OnCommand indeed does fire when you hit enter (if no pretranslate msg). But thanks for thinking about it...
Appreciate your help,
ns
|
|
|
|
|
I want to Create a Frame/view/doc structure On a ActiveX Control,but It will be Found Memory leak! And I Found that the
reasons is :
CDocManager* CDocManager::pStaticDocManager;
CPtrList* CDocManager::pStaticList;
How Can I avoid Memroy leak?
the Following is My Code :
BOOL Create()
{
if( m_pFrameWnd )
{
if( IsWindow(m_pFrameWnd->m_hWnd) ) return TRUE;
}
CSingleDocTemplate * pDocTemplate;
pDocTemplate = new CSingleDocTemplate(IDR_MAPTYPE,
RUNTIME_CLASS(CMapDoc),
RUNTIME_CLASS(CMapFrame),
RUNTIME_CLASS(CMapView));
CMapDoc * pDoc = new CMapDoc;
CCreateContext Context;
Context.m_pCurrentDoc = pDoc;
Context.m_pNewDocTemplate = pDocTemplate;
Context.m_pNewViewClass = RUNTIME_CLASS(CMapView);
Context.m_pLastView = NULL;
Context.m_pCurrentFrame = NULL;
CMapFrame * pFrameWnd = new CMapFrame;
m_pDoc = pDoc;
m_pFrameWnd = pFrameWnd;
m_pDocTemplate = pDocTemplate;
CRect rcMap;
GetClientRect(&rcMap);
BOOL ret = m_pFrameWnd->Create(AfxRegisterWndClass(CS_DBLCLKS), NULL, WS_CHILD|WS_VISIBLE, rcMap,this,NULL,&Context);
m_pFrameWnd->ShowWindow(SW_SHOW);
return ret;
}
ZHANGYIFEI
|
|
|
|
|
I need to work with encoded text files in visual studio environment. I can see two ways and two problems:
1. How can i override Save & Open methods of ITextDocument (IGenericDocument?)?
or 2. How can i change loaded document content without setting "saved" flag and how can i resave document to file without being asked by studio to "reload externally modified file"?
|
|
|
|
|
Hello,
This is a dumb question but I'm using the following to stream RTF from a .rtf file to a CRichEditCtrl.. The problem is that it's only reading in the 4096, I understand it's because my cBuf is only 4096.. Is there a way to read the whole file in with out having to declare the size of the cBuf char?? Heres my code..
CFile fileRead;
if(fileRead.Open(strFile,CFile::modeRead))
{
char cBuf[4096];
UINT uBytesRead;
while(uBytesRead = fileRead.Read(cBuf, sizeof(cBuf)-1))
{
cBuf[uBytesRead] = NULL;
SetRTF(CString(cBuf));
}
fileRead.Close();
}
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
You can use CRichEditCtrl::ReplaceSel to append text in to the control.
Pavel
Sonork 100.15206
|
|
|
|
|
It's not stopping at 4096.. but it is stopping before the end.. I wonder if the CRichEditCtrl has a text/size limit (I didn't declare one in my dialogs Init). I changed the 4096 to 1024 and it still reads in the same amount.. I re-wrote the code like this..
CFile fileRead;
if(fileRead.Open(strFile,CFile::modeRead))
{
char cBuf[1024];
UINT uBytesRead;
CString strBuff;
while(uBytesRead = fileRead.Read(cBuf, sizeof(cBuf)-1))
{
cBuf[uBytesRead] = NULL;
strBuff += CString(cBuf);
}
SetRTF(strBuff);
fileRead.Close();
}
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I think it is because your while ( condition ) is testing the result of an assignment operation instead of testing for an end of file condition. Try something like this
uBytesRead = fileRead.Read(cBuf, sizeof(cBuf)-1);
while ( uBytesRead == 1024 )
{
strBuff += CString(cBuf);
uBytesRead = fileRead.Read(cBuf, sizeof(cBuf)-1));
}
strBuff += CString(cBuf);
SetRTF(strBuff);
fileRead.Close();
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.
|
|
|
|
|
It still stops at the same spot.. Maybe theres something wrong with SetRTF.. weird, like the person said after your post, if im not reading the whole file the SetRTF wouldn't work because I wouldn't have a complete RTF string, so I'm guessing that this "read part" is probably working it's just not displaying the whole file... weird.
Any way thanks everyone for helping me, im going to look deeper into my SetRTF function. And im going to look at the string before SetRTF gets called.
Thanks again,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I think, You need to read the whole file and then set it, because of the RTF format which is structured, and can't be added into RichEdit in chunks split at random.
Pavel
Sonork 100.15206
|
|
|
|