|
You mean it appears to scroll backwards? It does this in Win2K also; it's apparently controlled the menu animation setting (desktop properties->effects->menu animation). You'll need to completely disable menu animation in order to fix it though; changing it to fade doesn't work.
---Shog9---
From now on we can call C# and MC++ "The square wheel languages" -- Jack Handy, The Lounge
|
|
|
|
|
yes, kind of backwards scrolling. So there is nothing I can do against it when using a listbox derived class? Is it a endusers choice?
|
|
|
|
|
'fraid so. At least you can blame it on MS ;~)
---Shog9---
From now on we can call C# and MC++ "The square wheel languages" -- Jack Handy, The Lounge
|
|
|
|
|
hehe. Oh you don't know how many 'winows API sux' comments I allready have in my sourcecode. )
But seriously, I came to a point where I think about reimplementing a listbox control for a chat (including emoticons and hyperlinks). I used a CListBox derived class and finally it works somehow, but it doesnt feed 100% to all my needs. I spyed on mIRC chat GUI, he used a static control in the chat output. That's a pure ownerdraw listbox-kind-of control, I assume.
Greets, Moak
|
|
|
|
|
Hio!
I am trying to allow my user to select any number of documents to print (classes derived from CFormView).. basicly they select a bunch of documents and in the CMainFrame i loop through their choices, call OnOpenDocument(), set the bottom view to the cformview, and call its BatchPrint() member function, which in turn calls CFormView::OnFilePrint()
the problem with this is that it pops up the printer selection dialog everytime..
so i have tried to create a CPrintInfo object and pass it to my BatchPrint() function, which has all of the actual code from CFormView::OnFilePrint()..
My OnPreparePrinting() only calls DoPreparePrinting() if the CPrintInfo hasn't been set once.. if its already been set then it uses the existing CPrintInfo.. my problem is that my CPrintInfo keeps getting the destructor called somehow before im done with it..
in any event.. is there a simpler way to switch a view, print a view (give print dialog), switch view, print view (no print dialog), switch view, print view (no print dialog), etc.. so the user only chooses the printer once..
any suggestions?
-dz
|
|
|
|
|
This code should get you going:
void CMyView::OnBatchPrint()
{
DOCINFO di ;
CPrintInfo printInfo ;
CMyDoc *pDoc = GetDocument() ;
CString filename ;
CDC dc ;
CRect draw_area ;
ASSERT_VALID(pDoc) ;
filename = pDoc->GetPathName() ;
filename.MakeLower() ;
CPrintDialog dlg(TRUE) ;
HDC hDC = dlg.CreatePrinterDC() ;
if (hDC == NULL)
return ;
di.cbSize = sizeof(DOCINFO) ;
di.lpszDocName = pDoc->GetPathName() ;
di.lpszOutput = filename ;
dc.Attach(hDC) ;
printInfo.m_bDirect = TRUE ;
printInfo.m_rectDraw.left = 0 ;
printInfo.m_rectDraw.right = dc.GetDeviceCaps(HORZRES) ;
printInfo.m_rectDraw.top = 0 ;
printInfo.m_rectDraw.bottom = dc.GetDeviceCaps(VERTRES) ;
draw_area = printInfo.m_rectDraw ;
dc.StartDoc(&di) ;
OnPreparePrinting(&printInfo) ;
for (printInfo.m_nCurPage = 1 ; printInfo.m_nCurPage <= printInfo.GetMaxPage() ; printInfo.m_nCurPage++)
{
dc.StartPage() ;
OnPrint(&dc, &printInfo) ;
dc.EndPage() ;
printInfo.m_rectDraw = draw_area ;
}
OnEndPrinting(&dc, &printInfo) ;
dc.EndDoc() ;
VERIFY(dc.DeleteDC()) ;
}
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
seemed like this code was going to work great by itself, but the call hDC = dlg.CreatePrinterDC(); always returns null..
i see that you declare a CPrintInfo and CDC var at the top, but they never get setup it seems.. i thought maybe i needed to do dc = GetDC(), but that returns a pointer instead of an actual CDC..
could you help a little bit more and let me know what I need to do to keep from falling out at the CreatePrinterDC command? and also help me understand how the CDC you declare gets set to the CDC of the view? thank you!
-dz
|
|
|
|
|
The only problem seems to be the CreatePrinterDC call. I copied that code from a procedure and moded it to use a CPrintDialog object to get the DC without checking it.
The MSDN says that you could get a HDC like this:
CPrintDialog dlg(FALSE) ;
HDC hdc = dlg.CreatePrinterDC() ;
The CDC created earlier in the procedure will be used to wrap the HDC returned from CreatePrinterDC() on the line dc.Attach(hdc), so you can use a standard CDC object when printing as expected by OnPrint() etc
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
plz check my new post for a continuation of this, thanks for yer help
-dz
|
|
|
|
|
Hi,
Could anyone tell me how to add a macro to active document in MFC?
thanks
Muddu
|
|
|
|
|
Could someone please tell me how one adds methods and properties(not functions and variables) in Visual C++7.0? In 6.0, we use to select the Automation tab in the Class Wizard and add methods and properties. It would also update the odl for us. What is the equivalent procedure or trick in 7.0?
Kind regards,
Tim
|
|
|
|
|
I discovered the answer to my own question and I'll answer it here in case someone else needs to do the same thing. I was expecting to add properties and methods by selecting the class in the ClassView and right clicking for the popup menu, but you can only add class member variables and functions. To add methods and properties to any interfaces in your classes, you need to find and select the application's type library listed in the ClassView. It is represented by a gray rectangle with rounded corners with a node extruding from the left side. If you expand the library, you will see a list of interfaces that exist in your project. Select the appropriate interface, right click, and add your methods and properties.
I hope this helps someone else.
Kind regards,
Tim
|
|
|
|
|
Hi,
I'm very surpised when I realized that std::string copy-costructor doesn´t create a new instance, just point to the older one
Try this code please.
You will get a memory fault error (VC6) when printing the copied string because destructor of first one has been called before
[code]
class CHexString {
private:
string m_byteStr;
public:
CHexString(const CHexString& hs) : m_byteStr(hs.m_byteStr) {}
CHexString(const char * hs) : m_byteStr(hs) {}
CHexString() {}
~CHexString( void ) { std::cout << "destroying " << m_byteStr << std::endl; }
const string getStr( void ) { return m_byteStr; }
friend std::ostream& operator<<(std::ostream os, const CHexString& hs) {
return os << hs.m_byteStr;
}
};
int main ( void ) {
CHexString hs0("JONNY");
CHexString hs1(hs0);
string hs2(hs1.getStr());
std::cout << "hs0 " << hs0 << " hs2 " << hs2 << std::endl;
//same error printing hs1 instead of hs2
return 1;
}
[/code]
Is this the normal behaviour to expect to?
Regards
Carlos.
|
|
|
|
|
No, this is definitely not normal behavior. I don't have any compiler at hand, but you might be so kind as to give this a try. Delete the const in getStr , as this:
string getStr( void ) { return m_byteStr; } Does the error persist?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Interesting you should ask this question as I was just having problems with std::string today (see my post below). I think your problem may have to do with the fact that MS's implementation of string uses reference counting. You might want to have a look here -- scroll down to the "Xstring" section. It details how reference counting can be disabled, which may be more expensive but worth the cost IMHO.
In any case, the bug fixes listed on that page should be useful to you if you are using MS's version of the STL.
--DG
|
|
|
|
|
Hello,
Check this answer posted in codeguru forums by John Barton (thanks John)
[quote]
It is normal behaviour for a string class to not copy the data but instead to do reference counting (unless the strings are different, there is no need to have multiple copies of the data).
The problem with your program is that you declared the operator<< incorrectly.
You should have made the first argument a reference:
friend std::ostream& operator<<(std::ostream& os, const CHexString& hs)
You were having a problem because when you called operator<< without the first argument being a reference, it made a local copy of the stream, and then returned a reference to the local copy (which was destroyed when the function exited).
Best regards,
John
|
|
|
|
|
CFileDialog dlg(TRUE, NULL, lastPath, OFN_ALLOWMULTISELECT,
_T("Text file (.txt)|*.txt|")
_T("All files (*.*) |*.*|")
);
...
if (dlg.DoModal() != IDOK)
DoSomething();
...
The above code works fine in the debug version, but curiosly enough, the dialog box hangs in the release version when a file is selected and the 'Open' button is pressed. Any ideas?
------------------------
Secondly, I have a set up like the following:
CClass1 {
...
vector<cclass2> data;
...
}
CClass2 {
//member funcs
private:
std::string str;
int x;
... (member variables)
}
CClass1* obj;
...
delete obj; //crash here
In my code I have a pointer to a CClass1 object (which I know is valid) that I am trying to deallocate. The program crashes when I call delete.
After much time spent, I know the problem arises when the last object in the data vector is deleted. I've tried using the default destructor to take care of deallocating the vector, I've tried calling data.resize(0);, data.clear();, and while (data.size()) data.pop_back(); -- all with the same result. Deleting the last object in the vector causes an assertion in dbgheap.c Expression:_CrtIsValidHeapPointer(pUserData)
More specifically, the assertion always occurs when the str member of CClass2 is being deallocated. Note that this is not a pointer to a string being deleted - it is a string object. Thus there should not be an issue with deleting the same string twice.
I thought maybe I had done something stupid and corrupted the heap along the way, but I've been looking over my code for a long time now and I'm fairly certain there are no double deletes, dangling pointers, etc. I know the above might not be very clear, but any insight would be appreciated.
Thanks,
DG
|
|
|
|
|
1. with multi-select, you have to provide a buffer big enough to store all the filenames.
2. hard to tell. try reposting with your code in PRE, /PRE brackets, or turn off the HTML stuff - looks like you lost some formatting.
-c
Cheap oil. It's worth it!
|
|
|
|
|
Tried the change you suggested for multi-select -- I removed it completely. The result is still the same. The dialog box still hangs with only one file selected.
As for the other code:
CClass1 {
...
vector data;
...
}
<BR>
CClass2 {
private:
std::string str;
int x;
... (member variables)
}
<BR>
CClass1* obj;
...
delete obj;
It's just code stubs, but hopefully that will look better for you. The main issue is just that it always fails when the str member is being deallocated. When unwinding the stack the last calls before the crash are:
1. The string destructor
2. basic_string::_Tidy()
3. std::allocator::deallocate
4. operator delete (void*)
(note that those are cleaned up names since everything is templatized...)
--DG
|
|
|
|
|
As for the first question, the strings must end with "||".
As for the second question, could you please repost checking the option "Display this message as-is (no HTML)" right below the edit area? That will bring the missing portions of the code into the light. Thank you.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi - does anyone know how to get the body type (RTF, HTML, TXT, etc.) of an message using Extended MAPI like you can in OOM? Also is there a way to duplicate the SavsAS in OOM with MAPI?
Thanks - BN
|
|
|
|
|
Hey...
I'm trying to make a simple little program that takes a string, searches for that string in a different string, and once that string is found, replace it with a different string. I want it to do this to the end of the string.
I'm kinda stuck right now, cause I don't know how to use the CString::Insert() and Find() functions right. I had a function that Replace()'d everything, but the problem was that I was trying to replace "\r\n" with "<br>\r\n", so it kept looping around and inserting till I had something that looked like: "Hello World<br><br><br><br><br><br><br><br><br><br>\r\n".
Also, in the replace function I'm using it uses lstrlen() functions, and I'm not *exactly* sure what those do.
If someone could point me to an article where it talks about things like this, or gave me some advice in a reply, I'd be very thankful.
Thanks, Emearg
The function I'm using:
CString CMFC2Dlg::Replace(LPCTSTR instr, LPCTSTR oldstr, LPCTSTR newstr)
{
CString output(instr);
CString input_lower(instr);
CString oldone_lower(oldstr);
input_lower.MakeLower();
oldone_lower.MakeLower();
int pos=0;
while ( (pos=input_lower.Find(oldone_lower,pos))!=-1 )
{
input_lower.Delete( pos, lstrlen(oldstr) );
input_lower.Insert( pos, newstr );
output.Delete( pos, lstrlen(oldstr) );
output.Insert( pos, newstr );
}
return output;
}
Called by:
LogConvert = Replace(LogString, "\r\n", "<br>\r\n");
|
|
|
|
|
|
Since you make a call to Insert when you replace the the search string with newstr you need to move pos past the newly inserted string. So, try this:
while ( (pos=input_lower.Find(oldone_lower,pos))!=-1 )
{
input_lower.Delete( pos, lstrlen(oldstr) );
input_lower.Insert( pos, newstr );
output.Delete( pos, lstrlen(oldstr) );
output.Insert( pos, newstr );
pos += lstrlen(newstr)
}
lstrlen returns the length of the argument you pass it (i.e. the number of characters contained in the string.
--DG
|
|
|
|
|
Awesome that worked. Thanks alot
|
|
|
|
|