|
hrmmm... it crashes ?
I have mod the code so it looks like this:
if (OpenDocumentFile(NULL) == NULL) {
AfxMessageBox("Could not create new file !");
}
CDocument* CGuitarBot_ComposerApp::OpenDocumentFile(LPCTSTR lpszFileName)
{
CDocument* pReturn = CWinApp::OpenDocumentFile(lpszFileName);
CGuitarBot_ComposerDoc* pDoc = (CGuitarBot_ComposerDoc*)pReturn;
return pReturn;
}
So it still does the same thing for open & new, just when I call New, i pass a NULL. Dunno ?
I really appreciate the help.
Rob
|
|
|
|
|
I posted that from memory, it's obviously wrong. Loading the project now..... I must say I'm surprised, you've done something odd because by default all this stuff is plumbed in for you. I almost started a guitar tab program myself once....
I have multiple templates and in CWinApp I force use of the first one like this:
POSITION POS = GetFirstDocTemplatePosition();
CDocTemplate* pTemp = GetNextDocTemplate(POS);
CGrausPaintDoc* pDoc = (CGrausPaintDoc*) pTemp->OpenDocumentFile(NULL);
which is why I expected OpenDocumentFile(NULL) to work. How did you create this project so that clicking File/New doesn't do it for you ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Yes, the project is pretty cool. Our team (myslef and 2 other beer drinking college guys) took it on from our client, a wireless data comm. guy who's done this in his spare time for the past 10 yrs.
We know nothing about music, and 1/2nothing about MFC.
I put my file open/new code in the GuitarBot_Composer.cpp class.
I wish I could answer why the open works and not the new ?
The open works fine but the new wont ? Shall I send some code your way ?
Many Thanks
Rob
|
|
|
|
|
robbied wrote:
The open works fine but the new wont ? Shall I send some code your way ?
Sounds like a good idea. I really don't see how this can be possible, because at the end of the day, MFC plumbs that stuff for you before you start.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I've got this odd problem with SetDIBitsToDevice - its strange because the function has been working fine for the past year or so, but now it doesn't work. I pass it the correct parameters, and a valid set of bits, and it even returns a success response, yet all it paints is blackness. The function works fine 8bit images, but fails with 24bit images !?! even if I use a screen res of 24bit If any of you can help... YadaYada yuno.
I'll try and answer someone else's question to maintain my code project carma 'ask one question one question give one answer'!
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Check the following:
a) RGB values are not packed (each pixel should take 4 bytes, not 3)
b) The biBitCount field in the BITMAPINFOHEADER structure is set to 32 instead of 8
c) The Width may need to be DWORD aligned as well, I don't recall if this is necessary for DWORD pixels
Chris Hafey
|
|
|
|
|
I just did a test and it doesn't need to be so restrictive (just change BPP from 1 to 4):
typedef unsigned char uchar;
void MyWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
const int Rows = 100;
const int Cols = 80;
const int BPP = 1;
static uchar* pData = 0;
static BITMAPINFOHEADER *lpbmiHeader = 0;
if(pData == 0)
{
pData = new uchar [Rows * Cols * BPP];
uchar* pOut = pData;
for(int i=0; i < Rows; i++)
{
for(int j=0; j < Cols; j++)
{
for(int z=0;z < BPP; z++)
{
*pOut++ = uchar(j) * 2;
}
}
}
short nInfoHeaderSize = sizeof(BITMAPINFOHEADER);
short nRGBQUADSize = 256*sizeof(RGBQUAD);
char* m_pBMI = new char [nInfoHeaderSize+nRGBQUADSize];
lpbmiHeader = (BITMAPINFOHEADER *) m_pBMI;
if(lpbmiHeader)
{
lpbmiHeader->biSize = sizeof(BITMAPINFOHEADER);
lpbmiHeader->biWidth = Cols;
lpbmiHeader->biHeight = Rows;
lpbmiHeader->biPlanes = 1;
lpbmiHeader->biBitCount = BPP * 8;
lpbmiHeader->biCompression = BI_RGB;
lpbmiHeader->biSizeImage = 0;
lpbmiHeader->biXPelsPerMeter = 0;
lpbmiHeader->biYPelsPerMeter = 0;
lpbmiHeader->biClrUsed =0;
lpbmiHeader->biClrImportant = 0;
}
RGBQUAD *ColorTable;
{
for(UINT i=0; i<256; i++)
{
ColorTable = (RGBQUAD*) (m_pBMI + sizeof(BITMAPINFOHEADER) + i*sizeof(RGBQUAD));
ColorTable->rgbBlue=i;
ColorTable->rgbGreen=i;
ColorTable->rgbRed=i;
}
}
}
::SetDIBitsToDevice(dc, 0, 0, Cols, Rows, 0, 0, 0, Rows, pData, (BITMAPINFO*) lpbmiHeader,DIB_RGB_COLORS);
// Do not call CWnd::OnPaint() for painting messages
}
|
|
|
|
|
I am trying to make a simple menu to run dos based programs. I can't figure out how to have the menu call the dos programs. I have read that there is a way to make stdout do this, but I can't find anything on this. Any help or advise would be great.
|
|
|
|
|
Try using the ShellExecute function to run your DOS programs, in the ON_COMMAND handler functions for each menu item. I never tried it for DOS programs, but it should work as well for DOS as Windows. You can find documentation on it in MSDN.
|
|
|
|
|
Hey guys
Does anyone know how to change a SYSTEMTIME in to a string that is for instance Febuary 12th 2001. I can't imagine there isn't a function to do this. So i would greatly appreciate if someone could tell me the name of the function.
Cheers
Peter
|
|
|
|
|
Try this:
SYSTEMTIME lCurrentDateTime;
char sFormatedDate[15];
GetSystemTime(&lCurrentDateTime); // get system date
GetDateFormat(NULL,
0,
&lCurrentDateTime,
"MMM dd',' yyyy",
sFormatedDate,
sizeof(sFormatedDate)); // format system date
Chris
campbell.chris@excite.com
www.SunAndGames.com
|
|
|
|
|
Yep that works, but you can also use the CTime or COleDateTime classes if you're using MFC.
SYSTEMTIME lCurrentDateTime;
GetSystemTime(&lCurrentDateTime);
CString strFormatted = COleDateTime(lCurrentDateTime).Format("%B %d, %Y");
CString strFormatted = COleDateTime::GetCurrentTime().Format("%B %d, %Y");
Regards,
Alvaro
|
|
|
|
|
It's bad to hard-code a date (or time or currency) format like that. Pass NULL for the format to have the API use the user's chosen date format.
--Mike--
http://home.inreach.com/mdunn/
While I can't be accurate on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
|
|
|
|
|
I've recently written a program that adds some new functionality to an existing off the shelf accounting program. I have no access to the source code of the accounting program. But, by using windows hooks within a DLL I was able to trigger the execution of my program when the user clicked on certain buttons within the accounting program. So, it appears to the user like I have actually modified the original program.
I would like to take this to the next level, and add my own buttons/controls to the screen of the accounting program. I've used functions like SetWindowsText, to change the text of another windows title bar, and FlashWindowsEx to flash another window. But, is there any way to actually add buttons/controls/menu items to the accounting program screens? I know this sounds kind of crazy, but it never hurts to ask.
The other approach I thought to take, would be to create my own window that anchors itself to the accounting program window, and place all the buttons/controls inside of it.
Any suggestions, or even crazy far fetched ideas are greatly appreciated.
Thanks, Chris
|
|
|
|
|
It sounds to me like you need two things:
1. Modify the app's existing resources, like menus, dialog boxes, etc.
2. Add your own functionality to your own menu items, buttons, etc.
Well, for the first point there's a nice tool I just read about in the Lounge (see, it helps to be a bum sometimes ) called ResourceHacker. That should get you started.
The second point you already have covered with hooks.
Regards,
Alvaro
|
|
|
|
|
Thanks Alvaro. Resource hacker is a cool tool. Just what I needed.
Chris
Chris
campbell.chris@excite.com
www.SunAndGames.com
|
|
|
|
|
Hello, the codegurus around the world.;)
I used to work the localization by loading the different langugage DLL.
So, this applies to your idea.
You can load the resource file by the different DLL.
If this DLL doesn't exit, the application loads the resource file in EXE file.
So, if you change something, (not add or delete the item from the resouce file), you can update only DLL without changing exe file.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Interesting stuff.
But creating your own modeless control box would seem to me as the safer option. Otherwise in future upgrades to your off the shelf software you may have to start from scratch. It would only take a change in menu structure or a remodel of the codes modular structure to bugger you up otherwise.
We do it for the joy of seeing the users struggle.
|
|
|
|
|
Hello,
I'm working on an MFC Application.
I would like to have a command line window where I can use tcl to call some functions , and call some tcl scripts.
Do you have any advice ?
Thanks,
Stephane
|
|
|
|
|
Hi All,
When you delete records from tables in a .MDB database file, the record space is marked as available, but is not removed from the file. So the file size grows over time.
As near as I can tell, the only way to reclaim that space is to compact the database. It would be really nice if the "available" space could be re-used by new records, but it doesn't look like this can happen. It would also be nice if you could compact just a single table in the database, but again, it looks like you have to do the whole .MDB file.
To compact a database, you must have exclusive access to it, and it must be closed (so how do you tell other applications to drop their connections to it?).
The database file must be compacted to a temporary file, and then the original deleted, and the temp file renamed.
This is a major pain when you have an application that is running ALL the time (and also when there are other apps also accessing the .MDB file).
Does anybody know of a way to reclaim the "available" space in a .MDB file, either by have the space be re-used for new records, by compacting only a table within the database, or by being able to compact the database without having to shut EVERYTHING down?
Thanks VERY much!
- Sean
|
|
|
|
|
I don't believe that can do that...
I think that is better pass to SQL Server, or to My Sql, it last one is very cheaper...
best Regards....
Carlos Antollini.
|
|
|
|
|
This is a Visual C++ app, using a CDaoDatabase (and the Jet engine).
My current solution is to check the database size at startup, and prompt the user to see if they want to perform a compaction if the database is larger than a certain threshold. The user is also prompted to shut down other applications which may be accessing the database.
The problem with this solution, is that it forces the user to periodically shut down and re-start the application (as well as other applications).
To do the compaction, I use the CDaoWorkspace static member function CompactDatabase. This works, but I wish there was a better solution.
Thanks - Sean
|
|
|
|
|
Yes I know that.
I worked with DAO several years, but the problem is that you need the database in exclusive mode for compact it. Is for this that I said you that I don't know if exist any solution, CDAOWorkspace need that nobody have the database open, for compact it.
May be Acces 2000 has some commands like SQL has but I don't Know....
Best Regards....
Carlos Antollini.
|
|
|
|
|
Hi all,
I wanna when user hited one of columns in the list control, program select all rows below the column !
and how can i understand user hited which column in list control ?
How can i do that ?
(Excusme about my English)
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|