|
|
|
I want to create a pager control using CreateWindow function at CMainFrame class of the application:
---------------------
if (CreateWindow(WC_PAGESCROLLER,NULL,PGS_HORZ|WS_CHILD, 0, 0, 0, 0, m_hWnd, NULL ,AfxGetInstanceHandle(),NULL) == NULL)
{
AfxMessageBox("Failed creating the pager control.");
return -1;
}
----------------------
The function returns NULL, which means failing in creating one. Can you help me to create the pager control?
Eilzabeth
|
|
|
|
|
First of all, you should call ::GetLastError() to see why the control isnt created.
And my first guess would be you forgot to call InitCommonControlsEx with ICC_PAGESCROLLER_CLASS.
Magnus
|
|
|
|
|
Yes, I did.
-------------------------
LPINITCOMMONCONTROLSEX lpInitCtrls = new INITCOMMONCONTROLSEX;
lpInitCtrls->dwICC =ICC_PAGESCROLLER_CLASS;
InitCommonControlsEx(lpInitCtrls);
if (CreateWindow(WC_PAGESCROLLER,NULL,PGS_HORZ|WS_CHILD, 0, 0, 0, 0, m_hWnd, NULL ,AfxGetInstanceHandle(),NULL) == NULL)
{
AfxMessageBox("Failed creating the pager control.");
return -1;
}
-------------------------
I have the code in the CMainFrame class at end of the OnCreate function.
Eilzabeth
|
|
|
|
|
And what return value do you get from ::GetLastError(); ?
Magnus
|
|
|
|
|
The GetLastError function returns a DWORD. How can I tell from such a number? At GetLastError documentation, it says use FormatMessage to get the error string. But I don't know how to do it. Can you help me?
Eilzabeth
|
|
|
|
|
I got the error message now. It says can not find window class.
Eilzabeth
|
|
|
|
|
Hi
One easy way to convert an error number is to use Error Lookup (under your tools menu in visual studio)
If it cant find the window class, then you get some error from InitCommonControlsEx, you should always check all return values from APIs as most of them report what went wrong with SetLastError().
If the code you sent is correct then you dont set dwSize of the INITCOMMONCONTROLSEX struct. And that makes InitCommonControlsEx fail.
Hope that solves your problem.
Magnus
|
|
|
|
|
I got it. I set the size to the size of the structure (dwSize = sizeof(INITCOMMONCONTROLSEX). Thank you.
Eilzabeth
|
|
|
|
|
I need to compare local file Date Last Modified times with the same times of files on a FTP server. I've used the CFileFind/CFtpFileFind classes to get the times in the form of CTime classes, but now how do I properly compare them? The local file times are in GMT-6 (sometimes with DST) and the server file times are GMT with no DST. Proper DST support isn't that critical (I can require people running my program to disable DST), but I still need to compensate for GMT. I haven't found a good way to compare two CTime classes, one in GMT and one not. I can use the GetGmtTm() function, but I don't know an easy way to compare two tm structs.
Thanks!
|
|
|
|
|
Take a look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/time.asp
it should have all information you will need.
Magnus
|
|
|
|
|
hello
how to add a color and icon to one button?
|
|
|
|
|
Plenty of articles on the site to show you how.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
but can you show just one exemple how the principal function used to do it?
|
|
|
|
|
Mate, if you can't type "button color icon" into the search dialog, then you really should not be using a computer.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Harsh
But I have to agree w'tch ya.
without being flamed of course!
"..Even my comments have bugs!"
Inspired by Toni78
|
|
|
|
|
How do you change the printer orientation once it has started?
I have used the samples that I can find on MSDN, but it does not change the orientaion. Like the MFCDVMD example. I use the DocumentProperties API and set the orientation, and it still does not work. I even tried ResetDC with the DEVMODE structure that I get back from DocumentProperties. Zippo!
Anyone have any suggestions?
Thanks in advance.
--Larry
|
|
|
|
|
Wrongwayf16 wrote:
How do you change the printer orientation once it has started?
You can't. If you need to do that, simulate it in your program (rotate all your drawing by 90 degrees). I think there's an article either here or at CodeGuru for a class called CRotDC which lets you draw as normal, and then rotate the entire image by a multiple of 90 degrees. That should help .
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Ryan,
Thanks for the reply. I will go take a look at CRotDC. I can change the orientation of the page in mid stream, the problem is that I only see text. I do not see any graphics. Like lines, rectangles, pics, ect...
I think I maybe corrupting the DEVMODE before I call ResetDC. If you have anymore suggestions or pointers to articals to help I would appericate it.
--Larry
|
|
|
|
|
It seems my reply wasn't totally accurate
ResetDC can be used after StartPage() to change the print orientation, but I can't remember ever getting it to work. I've just rotated the graphics output in software.
Perhaps I was just doing it the wrong way
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
It helps to reset the DC with the proper map modes! D'OH!
--Larry
|
|
|
|
|
Hello!
Does anyone know how can I catch the SetFocus event on a richedit control?
I tried with SetEventMask, I can catch mouse events, but what I need is to not allow
the user to set focus on a richedit.
Thanx.
Enis Arif
-----------
"I am enough of an artist to draw freely upon my imagination. Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world." (Albert Einstein)
|
|
|
|
|
just catch WM_COMMAND in parent window and check for EN_SETFOCUS.
Magnus
|
|
|
|
|
Thank you. Works great!
Enis Arif
-----------
"I am enough of an artist to draw freely upon my imagination. Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world." (Albert Einstein)
|
|
|
|