|
GetActiveWindow() - MSDN
The active window or NULL if no window was active at the time of the call. The pointer may be temporary and should not be stored for later use.
Try setting the window's active state explicity with SetActiveWindow() somewhere in your code and then try GetActiveWindow() see what happens...
If it's a temporary pointer...you only wanna use it right after the call to GetActiveWindow(), is this perhaps causing your problem...?
I dunno why it would fail...other than what the above states.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
CMDIFrameWnd::MDIGetActive() should do the trick.
|
|
|
|
|
You could try sending the WM_MDIGETACTIVE to the MDIClient window.
|
|
|
|
|
Is possible insert icons in a ListCtrl with owner draw fixed style ? How ?
Thanks ...
Cristiano
|
|
|
|
|
I don't see why not, however you'd have to handle to the drawing of the icons.
Your associating the icons with a CImageList, not the actual CListCtrl itself.
You'd have to get the image out of the imagelist and draw it to the DC passed to you in the DrawItem().
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hi,
I will set one event,if i call a messagebox after that everything works fine.Otherwise it hangs in waitforsingleobject().
I don't want to show any message box.so i did get/PostMessage+DispatchMessage.
It doesn't work..
Can anyone pl help me...
Neha
|
|
|
|
|
when i try to remove an item from a list inside of the loop it crashes.
here is my code:
list <sometype>::iterator i;
for (i=mylist.begin(); i!=mylist.end(); i++) {
if (...) {
mylist.erase(i);
}
}
|
|
|
|
|
if you want to be STL-friendly, use list::remove_if (see MSDN for a sample)
(the rest of the incorrect crap i posted earlier has been removed, to protect my good name)
-c
"Do you mind if I smoke?"
"Madam, I don't care if you burn."
-Oscar Wilde
Smaller Animals Software, Inc.
|
|
|
|
|
Chris Losinger wrote:
erase invalidates all iterators.
For std::list - are you *sure* ? My first reaction is that this is true of vector, but not list.
Remove_if is obviously a better way to go though
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
now that you've forced me to look it up... i'm sure i was wrong.
but, that was the explanation for the crash that sounded best. if that wasn't it, maybe there was something wrong with calling the destructor for the object in the list. yuk.
-c
"Do you mind if I smoke?"
"Madam, I don't care if you burn."
-Oscar Wilde
Smaller Animals Software, Inc.
|
|
|
|
|
Your iterator gets invalid. Do:
list <sometype>::iterator i;
for (i=mylist.begin(); i!=mylist.end(); i++)
{
if (...) {
i = mylist.erase(i);
}
}
and your iterator will be right on track.
|
|
|
|
|
I beleive this is correct however you should also do i--; after the erase() call because erase() returns the next iterator and it will get ++'d at the top of the loop therefore skipping the item after the one you erased. Hope this makes sense.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
I've made a MS Word automation project in order to print it's content
into Acrobat Distiller.
I want to print 3 pages (nPages = 3).
//---------------------------------------------------------------------------------------------------------------------------------------
So, my method is :
void _Document::PrintOut(VARIANT* Background,
VARIANT* Append,
VARIANT* Range,
VARIANT* OutputFileName,
VARIANT* From,
VARIANT* To,
VARIANT* Item,
VARIANT* Copies,
VARIANT* Pages,
VARIANT* PageType,
VARIANT* PrintToFile,
VARIANT* Collate,
VARIANT* ActivePrinterMacGX,
VARIANT* ManualDuplexPrint,
VARIANT* PrintZoomColumn,
VARIANT* PrintZoomRow,
VARIANT* PrintZoomPaperWidth,
VARIANT* PrintZoomPaperHeight )
{
static BYTE parms[] =
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT;
InvokeHelper(0x1bc, DISPATCH_METHOD, VT_EMPTY, NULL, parms, Background,
Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType,
PrintToFile, Collate, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn,
PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------
And, the following call to this method produces an exception, cause of COleVariant(nPages,VT_I4)
CString text;
m_Edit.GetWindowText(text);
_Application objWord;
// Convenient values declared as ColeVariants.
COleVariant covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
// Get the IDispatch pointer and attach it to the objWord object.
if (!objWord.CreateDispatch("Word.Application"))
{
AfxMessageBox("Couldn't get Word object.");
return;
}
objWord.SetVisible(TRUE); //This shows the application.
Documents docs(objWord.GetDocuments());
_Document testDoc;
testDoc.AttachDispatch(docs.Open
(
COleVariant(text,VT_BSTR),
covFalse, // Confirm Conversion.
covFalse, // ReadOnly.
covFalse, // AddToRecentFiles.
covOptional, // PasswordDocument.
covOptional, // PasswordTemplate.
covFalse, // Revert.
covOptional, // WritePasswordDocument.
covOptional, // WritePasswordTemplate.
covOptional, covOptional, covOptional), // Format. // Last argument for Word 97
(long)1 // Encoding // New for Word 2000/2002
); // Close AttachDispatch(.)
objWord.SetActivePrinter("Acrobat Distiller");
long nPages = 3;
SCODE sc;
TRY
{
testDoc.PrintOut(covFalse, // Background.
covOptional, // Append.
covOptional, // Range.
covOptional, // OutputFileName.
covOptional, // From.
covOptional, // To.
covOptional, // Item.
covOptional, // Copies.
COleVariant(nPages,VT_I4), // Pages.
covOptional, // PageType.
covOptional, // PrintToFile.
covOptional, // Collate.
covOptional, // ActivePrinterMacGX.
covOptional, // ManualDuplexPrint.
covOptional, // PrintZoomColumn New with Word 2002
covOptional, // PrintZoomRow ditto
covOptional, // PrintZoomPaperWidth ditto
covOptional); // PrintZoomPaperHeight ditto
objWord.Quit(covFalse, // SaveChanges.
covTrue, // OriginalFormat.
covFalse // RouteDocument.
);
sc = S_OK;
}
CATCH_ALL(e)
{
sc = COleException::Process(e);
CString exp;
exp.Format("%d", e);
MessageBox(exp, "Exception !");
}
END_CATCH_ALL
How can i do ?
Thanks.
|
|
|
|
|
How would you get from a managed string to an unmannaged char array? I know there must be a more elegant way to get from point A to point B than:
sName - String
mcName - Char __gc[]
cName - char* (allocated for 256;Assert sName.Length <= 255)
mcName = sName->ToCharArray();
for(int j=0;j<mcname->Count;j++)
cName[j]=Convert::ToSByte(mcName[j]);
cName[mcName->Count]='\0';
|
|
|
|
|
I want to catch when the mouse is leaving a button.
When the mouse is or, I want to show a text in a static when the mouse is ovedr the button. And then the mouse is leaving the static will show another text. HOOOW!!!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Subclass frmom CButton and overriden <coe>WM_MOUSEMOVE.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Yes, and how to know if the mouse is leaving the button!??
Thats the problemo dude!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
I'm not sure but test this one:
WM_CAPTURECHANGED
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Chris has a cool CButton derived class demonstarting subclassing...perfect example of tracking mouse entrance and departure.
Custom Button
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Rickard Andersson wrote:
Yes, and how to know if the mouse is leaving the button!??
Use SetCapture() to keep receiving the messages even when the mouse moves off of the control... don't forget to call ReleaseCapture() once you are done with it.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
Hi,
I have Windows 2000 Professional SP2 installed and I have built an OpenGL base MFC MDI application which works fine under WINNT 4.0. The problem I have with Windows 2000 is that, when I create more than one window, I get a black border on the window edges, which increases with every new window. This problem does not appear with nVidia GEForce MX 200. I suppose this is so because, nVidia provides its own ICD, wherease others use the generic implementation. Is there any way out of this problem??
Thanks in advance,
|
|
|
|
|
Could anyone please, please help me.
I've got a doc/view app with a modeless dialog(subclassed), in the dialog I have a tree, when I select an item, I'd like to refresh the main view. Simple enough I would have thought, but I can't get it to work.
Should I be using messages or is there a simpler approach, is this enough information?
I'm still learning MFC, any help would be much appreciated, thanks.
UndeadHamster
Bye
|
|
|
|
|
To keep the doucument/View design pattern intact, always keep relevant data in your doc object, and then redraw your view through the existing mechanisms for this purpose. In your case it could be something like:
call the SelectTreeObject from your dialog:
public: CMyDocument::SelectTreeObject(CMyTreeData* pData)
{
m_pSelectedObject = pData;
UpdateAllViews(NULL, ID_SELECTION_CHANGED, pData);
}
CMyView::OnUpdate(CView *pView, UINT lHint, CObject *pHint)
{
if (lHint == ID_SELECTION_CHANGED)
{
// Do your stuff here, e.g. call Invalidate()
}
}
In your OnDraw() handler you could ask your doc object for the selected tree object. Don't forget to #define your ID_SELECTION_CHANGED to some value.
|
|
|
|
|
Thanks a lot, your time is much appreciated
UndeadHamster
Bye
|
|
|
|
|
can i user dbGrid with CRecordset?
Best Regards
|
|
|
|
|