|
I havn't done this myself, but I guess you can change color by overriding OnCtlColor. Check for CTLCOLOR_SCROLLBAR in msdn.
If you would like a more custom draw get the scrollbars from the window using GetScrollBarCtrl and subclass them to your own derivation of CScrollBar.
/moliate
|
|
|
|
|
Yes, I`m want a more custom draw, but GetScrollBarCtrl returns NULL for windows style scrollbars
I would like to know, how can I subclass this scrollbars?
|
|
|
|
|
Hello, I want to display a clock on a dialog box. I want to do both an "analog clock" as well as a "digital clock". If you can help me as to resources to help me do this I would appreciate it.
Thanks.
|
|
|
|
|
You'll probably have to code an analog clock yourself, but how you would go about doing this would be to create a TIMERPROC, using SetTimer, that is updated every 1000 milliseconds or 1 second, then you would draw the analog clock every time the timer is executed according to the time provided by GetSystemTime. If you wanted the digital equivlant you would of course, just use GetTimeFormat, and print it out to the screen.
For a digital type look try :
http://www.codeproject.com/staticctrl/cstatictime.asp
Try MSDN for information on the stuff listed above.
Nathan
modified on Sunday, April 19, 2009 12:26 AM
|
|
|
|
|
Thanks, that is what I figured I would have to do. Thanks for your input.
|
|
|
|
|
To draw the clock face you'll probably have to resort to trigonomentry. You might be able to precalculate some values, though I doubt it.
If you want something more complicated than simple lines you have to create a vector image then rotate the points. I think Joseph M Newcomer has written an article on this.. but it's late so I'll leave you to find it .
Remember -
sin x = OPP/HYP
cos x = ADJ/HYP
tan x = OPP/ADJ. You can use the radius of your clock minus some value (to get the correct size so you don't draw over the numbers of the clockface) for the length of the hypotenuse (sic?).
--
Andrew.
|
|
|
|
|
|
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
|
|
|
|