|
|
Did u googled?
[^]
Величие не Бога может быть недооценена.
|
|
|
|
|
Adam Roderick J 09 wrote: Did u googled?
It's amazing that none of them can use Google but they all seem to be able to find us here.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Here[^] is a series of articles that covers the subject. BTW, a simple google search would have shown you already a lot of useful information.
|
|
|
|
|
Hi all,
i m working on SDI type application,in form view of application i want to load an image as a banner ant stretch it from top left to top right.
i do this with this code that is implement over OnPaint function.
everything is working fine.
CDC* dc=this->GetDC();
HDC memdc;
this->GetClientRect(&rect);
CBitmap bitmap;
bitmap.LoadBitmapA(IDB_HEADER);
BITMAP bm;
bitmap.GetBitmap(&bm);
int w = bm.bmWidth;
int h = bm.bmHeight;
memdc=::CreateCompatibleDC(dc->m_hDC);
::SelectObject(memdc,bitmap);
StretchBlt(dc->m_hDC,0,0,rect.Width(),50,memdc,0,0,w,h,SRCCOPY);
CString Title="";
m_Banner.GetWindowTextA(Title);
dc->SelectObject(m_Banner.GetFont());
dc->SetBkMode(TRANSPARENT);
dc->DrawText(Title, rect, DT_CENTER | DT_WORDBREAK);
problem is occur when the form scrolled with vertical scrollbar.
please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Le@rner wrote: problem is occur when the form scrolled with vertical scrollbar.
And what is the problem exactly ? First, what do you want to achieve? And then, what is your program doing which is wrong ?
|
|
|
|
|
when i scroll down the loaded image also moves down.
i want to stretch the image from top-left to top-right of form.its done by program.
please tell me how can i do this.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
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.
|
|
|
|
|
Hi
I tried to make a bitmap file from screen drawing. I used following function to get bitmaps data
GetDIBits(dc, hBitmap, StartScan, NumScans, m_pVoid, m_pInfo, Usage);
After I saved bitmap data to a file. I found that Bitmap was "rotated".
If the bitmap should look like: (Sorry, I don't know how to show a real bitmap here).
Each number is a pixel.
1234578
1234578
1234578
1234578
1234578
1234578
1234578
But I got:
5781234
5781234
5781234
5781234
5781234
5781234
5781234
What kind of reason will cause this?
Thanks,
modified on Monday, December 7, 2009 11:13 AM
|
|
|
|
|
What are you trying to do exactly ? What do you mean also by the bitmap should "look like" ? What are these numbers ? Bytes ?
Are you aware of the byte ordering (endianness[^]) ?
Without a bit more information about what you are doing exactly an what do you expect to have, it is very difficult to answer your question.
|
|
|
|
|
I can not put a real bitmap here. So I used some numbers here. These numbers mimic the bitmap what I got.
|
|
|
|
|
And ? An explanation of it would be usefull. Each number represents a pixel ? A byte ? Please, as already stated in my previous message, explain your problem clearly. We can't see what you are thinking and seeing you know.
You didn't even put any code how you "write" your bitmap (do you even write it back to a file ?)
|
|
|
|
|
Yes, Each number represents a pixel.
|
|
|
|
|
You cannot simply dump the bits into a file to create a BMP file.
A BMP file has a certain structure which consists of some headers before the actual data.
This article will give you an idea about saving to BMP files - Saving a Drawing to a Bitmap File[^]
|
|
|
|
|
I can open the bitmap file I created. It shows. But the image shown is wrong. The image was rotated (right part of image was moved to left side).
I also checked the bitmap data which I got from using "GetDibBits()". I found that data was rotated also.
Thanks,
|
|
|
|
|
That is exactly what I said.
It happens because the headers are not correct.
|
|
|
|
|
The pixel data of the bitmap are not put immediately after the header of the file. You need to check the documentation for the correct offset of the data in the file.
If you start from the wrong offset, the right hand side of each image scan line will show up in the left hand side, resulting in what you have gotten.
Hope this helps. Good luck!
|
|
|
|
|
As has already been suggested to you, you almost certainly have miscalculated the start position of the data in your file. That would easily explain the wrapping you have here.
To help prove / solve this, use (eg) paint brush, and make a bitmap there with the given colour depth / size. Then open that with a binary viewer, and compare its headers with yours. Hopefully that will show the mistake you've made.
These old formats are filled with versions, different behaviours, optional palettes, and other things that can be wrong very easily!
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
I want to install a service in such a way that if started from service manager then It should start from a particular user account and not from System account. How can this be done ??
Kushagra
|
|
|
|
|
If you just wanna use a "static" user (not dynamic) then just use the possibility to assign a valid user account and set this user instead of local system (second tab on service-properties).
Greetings
Covean
|
|
|
|
|
|
On install-time with service installer:
[RunInstallerAttribute(true)]
public class ControllerInstaller : Installer
{
public ControllerInstaller()
{
processInstaller=new ServiceProcessInstaller();
serviceInstaller=new ServiceInstaller();
processInstaller.Account=ServiceAccount.LocalSystem; <----------- here
serviceInstaller.StartType=ServiceStartMode.Automatic;
serviceInstaller.DisplayName = "DisplayName";
serviceInstaller.ServiceName = "ServiceName";
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;
} ;
or CreateService (Win-API).
At least look at the functions ChangeServiceConfig/ChangeServiceConfig2 if you want to change it "live"/for the next start.
Greetings
Covean
|
|
|
|
|
Thanks for the help
|
|
|
|
|
You can specify a valid user name and password in the lpServiceStartName and lpPassword parameters of the CreateService[^] API.
|
|
|
|
|
Thanks for help
|
|
|
|