|
Migrating from VB, I could not find an easy way to trap a return keystroke and then act apon it on a CEDit control. Update and Change don't pass a parameter telling you which key has been pressed. Have I missed something?
- X
|
|
|
|
|
You will have to subclass the control to be able to catch keystrokes.
See SubclassDlgItemin MSDN. Then add a handler for the WM_CHAR message.
Cheers,
/Fredrik
|
|
|
|
|
hi all,
are there any ppls meet this situation? the same program but the outlook is different in 2 pcs. actually, the 2 pcs i used have identical configuration. the OS is newly installed.
would anyone give me any idea?
here is the link of 2 outlook.
http://mail.hkibrc.org/~chaze/question/question.html
regards,
jim
|
|
|
|
|
Well, the obvious difference is in the font. The 2 PCs must not be identical if the same dialog box has a different font on each one. It looks like one is using Large Fonts, which you can turn off in the Display Settings.
Regards,
Alvaro
|
|
|
|
|
I just added a function to a foo.cpp module which makes use of std::ifstream. This function was required for Project A. When I went back to compile another Project B, which also uses foo.cpp but not the new function, it grew in size by 80k.
I assume there are some extra libraries that are getting linked in. Is there anyway to prevent this from happening? How do I know which libraries are getting linked in?
Todd Smith
|
|
|
|
|
Hello,
Christian was so much help last time, I hope he is around for this post.
I got the open a new doc/.view working (thank you )
But now I need to create just a new doc. Can't just call it but its constructor (that'd be too easy).
The earlier example created a CDocument that was cast into my Doc type, but now since I am just pressing the File > New button, there is no file to load, etc...
A tad lost
Rob
|
|
|
|
|
Where you passed in a poiner to a path to the document to load, pass in NULL to create a new one.
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
|
|
|
|
|
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.
|
|
|
|