Click here to Skip to main content
15,887,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question[Message Deleted] Pin
Benjamin Bruno7-Dec-09 18:15
Benjamin Bruno7-Dec-09 18:15 
AnswerRe: serialization Pin
Adam Roderick J7-Dec-09 18:24
Adam Roderick J7-Dec-09 18:24 
GeneralRe: serialization Pin
Tim Craig8-Dec-09 21:04
Tim Craig8-Dec-09 21:04 
AnswerRe: serialization Pin
Cedric Moonen7-Dec-09 20:21
Cedric Moonen7-Dec-09 20:21 
QuestionHelp - To draw image as banner with help of co-ordinates. Pin
Le@rner7-Dec-09 17:56
Le@rner7-Dec-09 17:56 
AnswerRe: Help - To draw image as banner with help of co-ordinates. Pin
Cedric Moonen7-Dec-09 20:31
Cedric Moonen7-Dec-09 20:31 
GeneralRe: Help - To draw image as banner with help of co-ordinates. Pin
Le@rner7-Dec-09 23:13
Le@rner7-Dec-09 23:13 
AnswerRe: Help - To draw image as banner with help of co-ordinates. Pin
Cedric Moonen7-Dec-09 23:48
Cedric Moonen7-Dec-09 23:48 
You mean that it always stays on top of your screen even when you scroll down and you like it to move upwards instead ?
If that's the case, what you have to do is keep the scroll offset in a member variable of your class: each time you scroll up or down, you calculate the offset that you have to apply to the drawings and you store it in the variable (and then request a repaint of your view). Then, in the OnPaint method you use this offset in the second parameter of the StretchBlt function (the y-coordinate of the upper-left corner of the destination rectangle). The scroll is not automatically managed for you, so you have to compute yourself the offset you will apply to the drawings so that they are positionned correctly.

There are also a lot of remarks for your code which is not really clean: you are for instance mixing calls to the MFC and calls to the Win32. It is not dramatic but it is really ugly. You should stick to one of the two, and as this is an MFC application, you should stick to the MFC API only (this could sometimes be really bad to mix the two).

CDC* dc=this->GetDC();

Why do you call GetDC ? You are in the OnPaint method so you receive the CDC as an argument and you should use that one.

HDC memdc;

Use the CDC class from the MFC instead of the win32 API

bitmap.LoadBitmapA(IDB_HEADER);

Never never call a specific type of a function like that. You should always call the generic version (LoadBitmap). If you have compilation errors, I strongly suggest you read this article[^] to have a better understanding of character encoding.

memdc=::CreateCompatibleDC(dc->m_hDC);

Once again you are calling the Win32 function and you should call the CDC::CreateCompatibleDC instead.

::SelectObject(memdc,bitmap);	
StretchBlt(dc->m_hDC,0,0,rect.Width(),50,memdc,0,0,w,h,SRCCOPY);

Same thing here.

m_Banner.GetWindowTextA(Title);

Same remark as before: use GetWindowText instead.

Cédric Moonen
Software developer

Charting control [v2.0]
OpenGL game tutorial in C++

QuestionBitmap [modified] Pin
transoft7-Dec-09 4:00
transoft7-Dec-09 4:00 
AnswerRe: Bitmap Pin
Cedric Moonen7-Dec-09 4:27
Cedric Moonen7-Dec-09 4:27 
GeneralRe: Bitmap Pin
transoft7-Dec-09 4:58
transoft7-Dec-09 4:58 
GeneralRe: Bitmap Pin
Cedric Moonen7-Dec-09 5:01
Cedric Moonen7-Dec-09 5:01 
GeneralRe: Bitmap Pin
transoft7-Dec-09 5:06
transoft7-Dec-09 5:06 
AnswerRe: Bitmap Pin
«_Superman_»7-Dec-09 4:31
professional«_Superman_»7-Dec-09 4:31 
GeneralRe: Bitmap Pin
transoft7-Dec-09 5:04
transoft7-Dec-09 5:04 
GeneralRe: Bitmap Pin
«_Superman_»7-Dec-09 5:47
professional«_Superman_»7-Dec-09 5:47 
AnswerRe: Bitmap Pin
loyal ginger7-Dec-09 5:23
loyal ginger7-Dec-09 5:23 
AnswerRe: Bitmap Pin
Iain Clarke, Warrior Programmer8-Dec-09 4:14
Iain Clarke, Warrior Programmer8-Dec-09 4:14 
QuestionRunning a windows service in any other account other than 'SYSTEM' Pin
Kushagra Tiwari7-Dec-09 3:38
Kushagra Tiwari7-Dec-09 3:38 
AnswerRe: Running a windows service in any other account other than 'SYSTEM' Pin
Covean7-Dec-09 4:13
Covean7-Dec-09 4:13 
GeneralRe: Running a windows service in any other account other than 'SYSTEM' Pin
Kushagra Tiwari7-Dec-09 4:22
Kushagra Tiwari7-Dec-09 4:22 
GeneralRe: Running a windows service in any other account other than 'SYSTEM' Pin
Covean7-Dec-09 4:32
Covean7-Dec-09 4:32 
GeneralRe: Running a windows service in any other account other than 'SYSTEM' Pin
Kushagra Tiwari7-Dec-09 5:46
Kushagra Tiwari7-Dec-09 5:46 
GeneralRe: Running a windows service in any other account other than 'SYSTEM' Pin
«_Superman_»7-Dec-09 4:33
professional«_Superman_»7-Dec-09 4:33 
GeneralRe: Running a windows service in any other account other than 'SYSTEM' Pin
Kushagra Tiwari7-Dec-09 5:47
Kushagra Tiwari7-Dec-09 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.