|
You cunningly place your cursor between the C and the View and type S-c-r-o-l-l. Seriously, you just need to derive your existing view from CScrollView instead, which means a few changes in the .h and .cpp file, and it will work. Look up CScrollView in the MSDN, I forget how to set the scrollable area off the top of my head.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
I also use this tricky method before.
But when I execute it, even there is no error and warning are detected.
The program will terminated when I open a new file. I dont know why
THX!!!
|
|
|
|
|
I am attempting to load an XML file using the DOMDocument 'load' method of the MSXML parser but it does not seem to be validating the file against the schema. The document will load ok and is even checked for correct XML syntax but doesn't validate against the schema.
Here is an outline of the code:
#import "msxml3.dll"
IXMLDOMDocumentPtr spDoc;
hr = spDoc.CreateInstance(__uuidof(DOMDocument));
if (FAILED(hr))
{
return 0;
}
// These properties are supposed to be set by default
// but just in case I make sure they are.
hr = spDoc->put_resolveExternals(VARIANT_TRUE);
if (FAILED(hr))
{
return 0;
}
hr = spDoc->put_validateOnParse(VARIANT_TRUE);
if (FAILED(hr))
{
return 0;
}
// Load and parse the input XML file.
_variant_t vFile(lpszXMLFile);
VARIANT_BOOL bSuccess = false;
hr = spDoc->load(vFile, &bSuccess);
if (FAILED(hr) || !bSuccess)
{
return 0;
}
The reference to the schema in the input XML file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<FreshItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Visual Studio Projects\Wcpw\Debug\FreshItem.xsd">
I suspect it is something to do with the reference to the schema since if I edit this to put in some bogus path it will still succeed to load, it looks like it is ignoring the schema reference altogether.
|
|
|
|
|
Hi,
I was in need to do a listview with 100x100x32 bitmaps/thumbs and I did so. But then a problem appeared, as the 9x windows don't seem to be able to handle the 330 neccessary items (13 megs in image list... ImageList_Add fails for one of the items, seemingly due to lack of resources). So I followed a fellows idea and did it over LVS_OWNERDATA. He told me making a 1-item image list and changing the image actually when the text is asked for. But here comes my problem:
1) I specify the ownerdata flag when creating
2) I specify the number of items in the listview control
3) The listview starts immediately asking me for texts... and I provide them... so far all right
4) It also asks for images. I provide them (the index = 0 and an appropriate image in the imagelist)
Problems
1) With that many items (330 and more), the application starts saying low on resources again. But mostly when I start moving thru the list itself. So it's a fault in my imagelist construction routines. Could someone send me his/her? Or is it because the incorrect appoarch?
2) I DO NOT add any items, I just specify the count and the control starts immediately asking me... Where's the fault?
It's kind of urgent and I would REALLY apperciate any ideas, hints, thoughts, suggestions, better appoarches. Thanks
|
|
|
|
|
If you're running out of resources you are creating DCs or HBITMAPs and not cleaning them up. Do you deselect everything you select into a DC before deleting it ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
HBITMAP hBitmap;
HGDIOBJ hOld;
HDC hDC,hTempDC;
RECT rect = {0, 0, 100, 100};
int width,height,x_offset,y_offset;
hDC = ::GetDC(Window->GetHWND());
hTempDC = CreateCompatibleDC(hDC);
hBitmap = CreateCompatibleBitmap(hDC, 100, 100);
hOld = SelectObject(hTempDC, hBitmap);
FillRect(hTempDC, &rect, (HBRUSH)GetStockObject(GRAY_BRUSH));
SelectObject(hTempDC, hOld);
m_Thumb->CreateFromHBITMAP(hBitmap); //this is a 3rd party lib and I assume it's correct
DeleteDC(hTempDC);
DeleteObject(hBitmap);
ReleaseDC(Window->GetHWND(), hDC);
}
the second one (there are two funcs working with this stuff is exactly the same, just that it returns the HBITMAP to another function which Adds it to image list and then DeleteObjects it
Thanks
|
|
|
|
|
All looks fine to me, except I'm not sure why hOld is not a HBITMAP ? That may be the problem, but I don't see why.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Can someone help my with the item addition issue then? Maybe I could find something there
|
|
|
|
|
You almost/kinda have it. I'm not sure what exactly m_Thumb->CreateFromHBITMAP( hBitmap ); does.
The theory is once you have a HBITMAP from your thumbnail you either use the CImageList Replace method if you're using MFC, or ImageList_Replace using straight win32. It looks like your 3rd party lib will give you a HBITMAP when you need it. Just use that to replace the 0th image in the imagelist.
If you need further help, let me know. What I do is slightly different. I store the raw image data using a FAST data (un)compression library and decompress it on-the-fly. Image lists tend to consume large amounts of memory when used exclusively. Once I figured out this method my app consumes about 1/10th the memory it used to.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Well, it seems like I'm unable to make the listview handle my handles properly or what... I still cannot figure it out. Could you contact me via e-mail? I need to discuss some related issues. My ICQ is 100419594 - thanks much for your help
|
|
|
|
|
I was told that I could debug with the OnSysCommmand handler. I cant find in the Clas wizard where it is to add it. Will it be a handler in the mainframe? Or the view? Anyways I dont see a SySCOMMAND message or anything likethatin theCW for mainframe class or view class...
Thanks,
ns
(I want to debug a crash that happens when I click the right cross system menu)
|
|
|
|
|
Add Windows Message Handler dialog has combo box "Filter for messages available to class". Select "window" in this combo, and you will see all messages, including WM_SYSCOMMAND.
|
|
|
|
|
I want to debug the crash when I close with the right hand x (WM_SYSCOMMAND). Which class should I put the handler in? The mainframe? Or the view? Or the doc?
Thank you
ns
|
|
|
|
|
|
Now that I've found the WM_SYSCOMMAND message, how exactly do I debug the crash? The handler is going to be empty, so what shall I put a breakpoint on?
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
CMDIFrameWnd::OnSysCommand(nID, lParam);
}
How does having an almost empty handler help you figure out why you are crashing when exiting wit the system right cross?
I must be missing something obvious!! Help!
Thanks,
ns
|
|
|
|
|
ns wrote:
How does having an almost empty handler help you figure out why you are crashing when exiting wit the system right cross?
It may not help. If your application crashes on exit, you probably have a big memory leak or something. Run the exe from the debugger and look at your ouput window in MsDev after you exit the application. See if it is reporting any memory leaks and so on..
Bijesh
------------------------------------------
|
|
|
|
|
Since this crash was happening after several times of rerunning a particular function, I looked at it, found a new char being created, and never deleted. It was a pretty big char array. SO I did a delete and set the pointer = NULL. Are these two steps the right thing to do? In my main app, I have lots of 'new' variables but they are all small and in 90% of the places I dont delete them . But since this turns out to be a cumulative problem, I am going to weed them out and delete them, and NULL them. Is the NULL a good practice or unnecessary?
Thanks,
ns
|
|
|
|
|
ns wrote:
But since this turns out to be a cumulative problem, I am going to weed them out and delete them, and NULL them. Is the NULL a good practice or unnecessary?
Thanks,
Its a good idea to NULL the pointer as soon as you delete it. You can combine that practice with checking for NULL before you use a pointer .
But.. it is very important to delete any memory(objects, variables etc) that you allocate with new. Smaller variables may not cause a problem initially, but they do accumulate like you said. Also if the application is used for long periods of time, the smaller memory allocations accumulate and cause a problem. So always 'delete' what you 'new'
Bijesh
--------------------------------------------------
|
|
|
|
|
I've got several member variables that are pointers and get used all the time. I am new at this stuff (no pun) so I am afraid to delete these since I access them all the time - for example some of these are doc variables that I access from several places at several times. I am deathly afraid I'll mangle my app if I delete these in the wrong place. Other than these, I've cleaned up my code.
Thanks,
ns
|
|
|
|
|
Hi all,
Whenever I insert a new dialog resource into my project, the dialog's font is System 8, which makes the dialog look odd when it's displayed. I'd like it to default to MS Sans Serif 8, which is what it used to be(I think). How can I change the default font for dialog resources? I'm using EVC.
Thanks!
Wes
Sonork ID 100.14017 wtheronjones
|
|
|
|
|
Open the .rc file up in a text editor (notepad works),
look for the text for the dialog you want to change that looks similar to this:
IDD_ABOUTBOX DIALOGEX 0, 0, 140, 57
STYLE WS_POPUP | WS_CAPTION
EXSTYLE WS_EX_CAPTIONOKBTN
CAPTION "About MyDialog"
FONT 8, "System"
and change the last line to be FONT 8, "MS Sans Serif"
I've never done this myself, but it should work.
|
|
|
|
|
thanks for the post. that'll work for a single dlg. I can also get the same effect w/ the property dialog...on the General tab there's a btn to change the font. I'm kinda hoping to figure out the way to set the default font used for dialogs each time one is inserted.
thanks!
Wes
Sonork ID 100.14017 wtheronjones
|
|
|
|
|
I want a program where there is a a list on the left part of the window and a edit control on the right. I can get the edit control, but not the list control. I tried having my program starting with the explorer view, set when I made a new program, and changing all the CTreeView to CListView. That gave me all the CListCtrl functions but I can't get the colums of the lists with the titles to appear. How can I get them to show? Should I be taking a different approach?
-Raffi
|
|
|
|
|
- Make sure the list is in report view mode
- Make sure you've added columns *before* trying to add items
- Make sure you've added items
- Make sure the columns have greater than 0 width
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
Thanks for the tips. Works great now.
-Raffi
|
|
|
|