|
|
I've already done this in a batch file, but in the C++ compiled code, it has system("Myapp.exe").....I'm trying desperately not to change any code.....
I was going to change the environment var in the Registry, from cmd.exe to command.exe....this works...but results undefined .
Thanks.
Gerry.
|
|
|
|
|
I'm looking into developing an app that needs to have a slight twist on the doc/view architecture, and I'd like some opinions.
In a nushell, we'd like to have an Explorer-type interface, but with the tree containing multiple documents. The top level of the tree would contain N documents, and the data within each document, which is organized hierarchically, would be displayed as children of the documents.
The wrinkle here is that the window containing the tree is outside the normal doc/view paradigm; it not only displays a "list" of available documents, it also displays data for each document. I know how to deal with the latter problem - I'll bypass the UpdateAllViews() mechanism in MFC and replace it with a custom Publish/Subscribe scheme - but how to deal with the tree window?
So far, two ideas have occurred to me:
1) Make the tree window be a child of the mainframe, and not a view; that is, something analogous to a permanently docked control bar.
2) Create a phony "master document", which references all the other documents, and then have this window be a view into the master doc.
I'm still kicking ideas around, but tonight I'm leaning toward 1). Thoughts? Suggestions? References? Catcalls? (I suppose for you Aussies, these would be Koala calls...)
TIA
Jim Johnson
|
|
|
|
|
Regarding getting a list of documents, there's a built-in way to do that. Look at CDocTemplate::GetFirstDocPosition() and CDocTemplate::GetNextDoc()
--Mike--
http://home.inreach.com/mdunn/
The preferred snack of 4 out of 5 Lounge readers.
|
|
|
|
|
i used the second approach in a project a couple of years ago that sounds vaguely similar to yours ... both ways will leave you grunging around in plumbing issues to make the right things visible to the right things so to speak
i ended up with a master doc of a bunch of pointers to the other docs and views ... all i had to do was manage the pointers and swap stuff around as needed
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I am looking for an algorithm to match an RGB value to the nearest color in a table of values without having to realize a palette.
Any suggestions would be most welcome.
Happy programming!!
|
|
|
|
|
MSJ had an article on OctTrees several years ago (96/97?).
That would do what you want. It fast too. It was a 'wicked code' article.
I think it was written by Jeff Prosise, but can't remember. You can find it
and the code example on the MSJ website.
Stephen Kellett
|
|
|
|
|
The URL is http://msdn.microsoft.com/library/periodic/period97/wicked1097.htm
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
I am writing a small program in C++ without MFC(call me a glutton for punishment, but I want to avoid the hassle of the dependancy). The premise of the program is that it will delete all of the files in a given directory if the file is older than a given number of days. 99% of the application works fine, except the code below:
FILETIME ft;
ULONGLONG qwResult;
ft = getTimeInFiletime();
//ULONGLONG localAge = (ULONGLONG)age;
// Copy the time into a quadword.
qwResult = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
// Subtract x days.
ULONGLONG lngDaysToSubtract;
lngDaysToSubtract = age* _DAY; //Note: _DAY is a ULONGLONG, a.k.a __int64
qwResult -= lngDaysToSubtract;
// Copy the result back into the FILETIME structure.
ft.dwLowDateTime = (DWORD) (qwResult & 0xFFFFFFFF );
ft.dwHighDateTime = (DWORD) (qwResult >> 32 );
This code is creating a FILETIME structure that will contain the "cuttof date", for example if someone calls the program with a parameter of 30 days, it will create a FILETIME structure containing the date of 30 days ago. The problem here is this line:
lngDaysToSubtract = age* _DAY;
"age" is an int parameter passed into this function. If I replace this variable with a hard-coded parameter, say 30, this code works fine. But it fails if I use the function parameter. If I throw in a "printf("Age is: %s\n",age);", it shows that the value is what I expect it to be.
I have been banging my head on this problem all morning. If anyone can help me solve it, I would be extremely grateful!!
Thanks
|
|
|
|
|
"age" is an int parameter passed into this function. If I replace this variable with a hard-coded parameter, say 30, this code works fine.
That tells me that "age" is too small of an integer. A normal int only holds up to ~2B and depending on what the value of _DAY is, that multiplication is probably overrunning the capacity of an int. Change "age" to ULONGLONG, or cast "age" to ULONGLONG in the multiplication, and I bet it'll work.
--Mike--
http://home.inreach.com/mdunn/
The preferred snack of 4 out of 5 Lounge readers.
|
|
|
|
|
Is it possible to replace the ComboBox popup arrow button with a image of my own?
Any links/exmplantions appreciated.
|
|
|
|
|
Hi,
I'm pretty new to C++ windows and i'm getting a little stuck. I'm trying to get a dialog based app going with a simple bitmapped ui. I dont want to use any of the skin librarys available here because they are a bit over the top for my needs.
I made a basic dialog based mfc project, stripped title bar and borders off the dialog, and use OnPaint() to bitblt a bitmap onto the background. i then call CDialog::OnPaint() which (in my understanding) has windows deal with painting of the two child buttons on the dialog.
This so far actually worked, which impressed me. Then I wanted to make the window draggable by clicking anywhere on the background. So I use a comboination of OnLButtonDown, OnLButtonUp and so on to facilitate this.
This almost works right. Mostly you can drag the window round just fine, but sometimes the child buttons on the window dissapear. this especially seems to happen if you drag the window to the top of the screen and down again.
I cannot figure out for the life of me why this occurs. i found a rather poor workaround in that calling SendMessage(WM_PAINT,0,0) at the end of OnMouseMove makes sure the buttons dont dissapear, but this slows everything down and makes the window flicker badly when being dragged.
Can anyone help me identify why the buttons sometimes dissapear?
The VC6 project and assocated files are available at:
http://www.atomichamster.org/bitmapui.zip
The download is about 50k
Looking forward to hearing your replies.
Thanks
Jon
|
|
|
|
|
first, you probably shouldn't call OnPaint yourself. a better way is to call Invalidate(FALSE); this has much the same effect as calling OnPaint directly, in fact it will end up calling your OnPaint eventually, but does some other nice thigns, too. read the help for Invalidate and InvalidateRect, they're nice functions.
second, if you're getting flickering, then you are trying to draw too much stuff at once. in OnPaint, you need to determine what needs to be drawn: call CDC::GetClipBox to get the rectangle that needs to be updated and only paint that part.
another way to reduce flickering, but this only really helps if you're doing multiple draws, and not just a single bitblt, is to render onto an off-screen dc then bitblt the whole thing at once.
yet another way to reduce flickering, and one that might help you, is to override the OnEraseBackground function (use classwizard). just return FALSE;. this tells MFC not to re-paint the window's background every time it redraws.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
i call OnPaint because I override the base class's OnPaint function in order to paint the background myself.
When i'm done there, i call the base class implementation of OnPaint to have windows carryon doing its stuff.
If I don't do this then windows never draws the child buttons at all!
Am I severly missing the point here or what?
I'll definitely try the other recommendations though. I realise that always invalidating the whole window was a bad idea, but it seemed to force the drawing of the buttons. I'm thinking that I shouldnt need to do that at all- surely windows should always draw the buttons for me?
jon h
|
|
|
|
|
one reason to call Invalidate instead of OnPaint is that there is a very good chance that there may be things that have to happen before OnPaint is called that Invalidate takes care of. so, Invalidate will do some setup, then call your OnPaint when it's ready (in effect). and, yes you should always call the base class OnPaint - so that the buttons can draw themselves, too.
another reason for not calling OnPaint directly is that painting is supposed to be asynchronous - the UI updates when it gets a chance, not when you decide it should.
overriding OnEraseBackground will take care of the background issue for you.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
The reason you're getting strange results when overriding OnPaint() is you're not handling the right message. WM_ERASEBKGND was designed specifically for what you want to do. Override OnEraseBkgnd() and paint your bitmap, and the dialog controls will come out fine. I have done exactly what you are doing with a dialog, so I know this method works.
--Mike--
http://home.inreach.com/mdunn/
The preferred snack of 4 out of 5 Lounge readers.
|
|
|
|
|
That totally works!
Thankyou very much!
The MFC approach to life it a bit confusing at the moment, but I'm beginning to get the hang of it.
Next step: adding transparency!
expect me back in a few days.
Jon h
|
|
|
|
|
Just in case, this is what is really working for me since 5 yeras! Use it if you wish!
void CxxxxxxDlg::OnPaint()
{
CPaintDC dc(this);
if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDC memDC;
memDC.CreateCompatibleDC(NULL);
CBitmap Bitmap;
Bitmap.LoadBitmap(IDB_BITMAP_BACK);
memDC.SelectObject(&Bitmap);
CRect rect;
GetClientRect(&rect);
LPBITMAPINFOHEADER m_pBmInfoHeader;
UINT width = (UINT) m_pBmInfoHeader->biWidth;
UINT height = (UINT) m_pBmInfoHeader->biHeight;
dc.BitBlt(rect.left,
rect.top,
width,
height,
&memDC,
0,
0,
SRCCOPY);
CDialog::OnPaint();
}
}
And there has never been a need for WM_ERASEBACKGND so far!
PS. For your next questions, to prduce Transparency you must have Mask bitmaps and prepare either by writing code or yet simpler just produce a B&W version of your bitmap and then use it as a mask.
Keep in mind that if you are going to use bitmaps as a background to your dialog window, you must go some steps further than just tranparenting the bitmap, you gotta create a region from it and let that
region be the dialog drwaing clip regions/window.
Advice: Use the samples from codeguru or even here on codeproject and save yourself a lot of time!
However, Good Luck!
|
|
|
|
|
Does anyone know how to make those Title bar, Menu bar, Tool bar, Status bar disappear, so that I have more space for the document on the screen? My program is a SDI project.
Thanks
|
|
|
|
|
Hi,
I would like to associate an acclerator (for example Ctrl+S) to a button in a dialog window.
What do I have to do ?
I just have a function associated with the button ID.
Thanks.
Rob.
|
|
|
|
|
Hi
I have a small problem, which might seem ridicolous. I have an extended combobox and a toolbar om a dialogbar. To my surprise, I can't find any way to react when the user presses the enter button in the edit-part of the combobox. The action I want is the same as the one when the user presses a button on the toolbar.
Any hints?
|
|
|
|
|
search MSDN for "Subclassing a Combo Box". there is an example there showing how to catch the enter, esc, and tab keystrokes for comboboxes on a toolbar.
|
|
|
|
|
Using the Ultimate Grid (UG) very successfull for years, I now want do do some custom drawing.
Has anyone made an enhanced version (e.g. an OnDrawCell() handler, etc.) that I could buy/get/use?
Uwe Keim
See me: www.magerquark.de
|
|
|
|
|
Hi Uwe,
I think the correct way is to dereive a new class from "CUGCellType"
and overwrite the "OnDraw" method. I've done this in one of my projects.
If you need further information, don't hesitate to contact me.
Best regards
Holger
|
|
|
|
|
Hi,
I need to develop a plug-in for IE, that would be able to get the current URL (and detect it's changes).
The problem is that I don't even imagine where to begin!
Can anyone point me source code that:
- creates the toolbar under Internet explorer
- get the URL changes (automatic)
I looked @ the docs in MSDN, but they pointed me nowhere...
Tutorials are very welcome. The plug-in is in the style of the Google and Altavista style.
Thanks in advance!!
Marcelo Nogueira Magri
[Senior ASP Developer]
[Newbie VC++ Developer]
|
|
|
|