|
Hi,
I am merging 5 bmp's and displaying them as a single bmp in the OnDraw(). The bmp does not get scrolled when i move the
scrollbar.Instead if i draw a rectangle it gets scrolled when i move the scrollbars, why does not the bmp get scrolled?
Thanks and regards,
Salil.
void CAprsView::OnDraw(CDC* pDC)
{
CAprsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CString szFilename("d:\\vc\\mfc\\2001.bmp");
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL,szFilename,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp;
bmp.Attach(hBmp);
CClientDC dc(this);
CDC bmDC;
bmDC.CreateCompatibleDC(&dc);
CBitmap *pOldbmp = bmDC.SelectObject(&bmp);
BITMAP bi;
bmp.GetBitmap(&bi);
dc.StretchBlt (0,0,len_in_pix,ht_in_pix,&bmDC,0,0,bi.bmWidth
,bi.bmHeight,SRCCOPY);
bmDC.SelectObject(pOldbmp);
CString szFilename1("d:\\vc\\mfc\\2002.bmp");
HBITMAP hBmp1 = (HBITMAP)::LoadImage(NULL,szFilename1,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp1;
bmp1.Attach(hBmp1);
CClientDC dc1(this);
CDC bmDC1;
bmDC1.CreateCompatibleDC(&dc1);
CBitmap *pOldbmp1 = bmDC1.SelectObject(&bmp1);
BITMAP bi1;
bmp1.GetBitmap(&bi1);
dc1.StretchBlt (0,br_in_pix,len_in_pix,ht_in_pix,&bmDC1,0,0,bi.bmWidth
,bi.bmHeight,SRCCOPY);
bmDC1.SelectObject(pOldbmp1);
CString szFilename2("d:\\vc\\mfc\\2003.bmp");
HBITMAP hBmp2 = (HBITMAP)::LoadImage(NULL,szFilename2,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp2;
bmp2.Attach(hBmp2);
CClientDC dc2(this);
CDC bmDC2;
bmDC2.CreateCompatibleDC(&dc2);
CBitmap *pOldbmp2 = bmDC2.SelectObject(&bmp2);
BITMAP bi2;
bmp2.GetBitmap(&bi2);
dc2.StretchBlt (0,br_in_pix+ht_in_pix,len_in_pix,br_in_pix,&bmDC2,0,0,bi.bmWidth
,bi.bmHeight,SRCCOPY);
bmDC2.SelectObject(pOldbmp2);
CString szFilename3("d:\\vc\\mfc\\2004.bmp");
HBITMAP hBmp3 = (HBITMAP)::LoadImage(NULL,szFilename3,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp3;
bmp3.Attach(hBmp3);
CClientDC dc3(this);
CDC bmDC3;
bmDC3.CreateCompatibleDC(&dc3);
CBitmap *pOldbmp3 = bmDC3.SelectObject(&bmp3);
BITMAP bi3;
bmp3.GetBitmap(&bi3);
dc3.StretchBlt (0,2*br_in_pix+ht_in_pix,len_in_pix,ht_in_pix,&bmDC3
,0,0,bi.bmWidth,bi.bmHeight,SRCCOPY);
bmDC3.SelectObject(pOldbmp3);
CString szFilename4("d:\\vc\\mfc\\2005.bmp");
HBITMAP hBmp4 = (HBITMAP)::LoadImage(NULL,szFilename4,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmp4;
bmp4.Attach(hBmp4);
CClientDC dc4(this);
CDC bmDC4;
bmDC4.CreateCompatibleDC(&dc4);
CBitmap *pOldbmp4 = bmDC4.SelectObject(&bmp4);
BITMAP bi4;
bmp4.GetBitmap(&bi4);
dc4.StretchBlt (0,2*br_in_pix+2*ht_in_pix,len_in_pix,20,&bmDC4
,0,0,bi.bmWidth,20,SRCCOPY);
bmDC4.SelectObject(pOldbmp4);
}
void CAprsView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: calculate the total size of this view
CSize sizeTotal(2000,3000);
CSize sizePage(sizeTotal.cx/2,sizeTotal.cy /2);
CSize sizeLine(sizeTotal.cx/2,sizeTotal.cy /2);
// TODO: calculate the total size of this view
//sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal,sizePage,sizeLine);
}
|
|
|
|
|
Dear All,
I am developing an application for Windows 2000 NTFS file systems using VC++ MFC version 6.0. I need to query whether "Norton antiviral" is installed on a system or not.
We know that Norton Antivirus runs as a service. So to find its existence I suppose, I should query whether the service for Norton exists of not in the system. So my query is that
"Is there any API provided to know existence of a service given its name. (In this case, navapscv is the name of the service, also we know its rest of parameters like display nameless)"
Or, is there any alternate way to accomplish the same task?
Please let me know if you need further clarification in this regards,
Regards,
Rohit
|
|
|
|
|
try to open the service
SC_HANDLE OpenService(
SC_HANDLE hSCManager, // handle to SCM database
LPCTSTR lpServiceName, // service name
DWORD dwDesiredAccess // access
);
this function returns
ERROR_INVALID_NAME
ERROR_SERVICE_DOES_NOT_EXIST
not sure which one exactly
greatest thing is to do wot others think you cant suhredayan@omniquad.com>
messenger :suhredayan@hotmail.com
|
|
|
|
|
Hi...
I'm still having problems with vectors. Can somebody provide me with d correct code that can b guaranteed to both of d above?
Thank you.
|
|
|
|
|
Hi All,
I have a structure of CString variabls.I need to pass this variable from one application to other application.I was trying WM_COPYDATA message to pass the data but i'm unable to receive the structure in the destination process.can someone help me out in this.
my code looks like this
typedef struct
{
CString name;
Cstring job;
} Raghu;
Raghu raghu;
raghu.name = "Raghu";
raghu.job = "none";
COPYDATASTRUCT datastruct;
datastruct.lpdata = (void*)&raghu;
datastrcut.cbdata=raghu.name .getlength() + raghu.job.getlength();//is this correct way??
::SendMessage(HWND_BROADCAST, WM_COPYDATA, (WPARAM)this->GetSafeHwnd(), (LPARAM)&datastruct);
Thanks in advance
|
|
|
|
|
You can't pass pointers between process WM_COPYDTA
designated for transfer easy weight data (no more than LONG)
You can shared data among process use memory mapped files
or use __declspec(allocate) see MSDN or "Ritcher Programming for Windows"
|
|
|
|
|
You can't used class with WM_COPYDATA. Only like this.
typedef struct
{
char name[256];
char job[256];
} Raghu;
Raghu raghu;
strcpy(raghu.name, "Raghu");
strcpy(raghu.job, "none");
COPYDATASTRUCT datastruct;
datastruct.lpdata = (void*)&raghu;
datastrcut.cbdata=sizeof(raghu)?
::SendMessage(HWND_BROADCAST, WM_COPYDATA, (WPARAM)this->GetSafeHwnd(), (LPARAM)&datastruct);
---------------------------
Auto Debug for Windows
website: http://www.autodebug.com/
|
|
|
|
|
Hi,
Thanks for the suggestion.
The code works.but whenever i send this broad cast message microsoft outlook gives a message
"The command line argument is not valid. Verify the switch you are using.".
i tried giving different value to datastruct.dwData variable.but is of no use.can you please help me on this
Regards
Raghu
|
|
|
|
|
if you broadcast a message, all the apps are geting it and if they have a function mapped to this message, you get funny results.
you mustnt broadcast a message. send it to a particular window.
|
|
|
|
|
Hi
I have a problem with windows API in VC++ 6.0 and I hope someone helps me.
Consider two dialog boxes which use the same WndProc, all I want to do is to know which dialog has called the WndProc at a time.
To create a dialog box I use the "CreateDialog" API and I think my answer has something to do with "GetDlgCtrlID" function. But this function always returns zero!! So I'm stuck and don't know what to do..
Really appreciate any help
Mehran Ziadloo
|
|
|
|
|
I have a structure like this:
typedef struct tagInputFields
{
UINT nMask;
CString field1;
CString field2;
CString field3;
CString field4;
CString field5;
CString field6;
} what I'm wondering is if it's possible to overload the [] operator to offset into the structure. If so I would appreciate an example of how I might do it as I'm lost. So for example if I put
m_ifFields[1] Thanks.
- Aaron
|
|
|
|
|
This would be a really bad idea since it would be totally confusing to anyone reading your code!
Why don't you do it like this:
typedef struct tagInputfields
{
UINT nMask ;
CString fields[5] ;
} ;
CString val = m_ifFields.fields[1] ;
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin
Awasu 2.0 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
I dont know wheather [] operator can be overloaded in struture, but you can always use class and over load it, it wont make any change in the usage.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Hi Prakash, in C++, a struct is the same as a class except that all the members of a struct are public by default.
class AA
{
public:
AA() { }
};
struct BB
{
BB() { }
};
Maxwell Chen
|
|
|
|
|
First you have to decide whether you want the result of operator[] to be an lvalue (meaning, you can assign to the result). Let's assume no for the time being. It's customary to have two versions, one for const this and one for non-const this to maintain the best const -correctness. It would go like:
CString tagInputFields::operator[](int idx)
{
switch ( idx )
{
case 1: return field1; break;
case 2: return field2; break;
default:
return _T("");
}
}
const CString tagInputFields::operator[](int idx) const
{
switch ( idx )
{
case 1: return field1; break;
case 2: return field2; break;
default:
return _T("");
}
} Yes, the two are identical except for the function prototype. That is, again, pretty normal since you are returning the same thing in each case, it's the prototype that makes the data const or not.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|
|
Thanks for the help Mike, I'll give that a try and see how it works out.
Thanks again.
- Aaron
|
|
|
|
|
How can i know name of the currently running application in win 2000? Where they are stored ,is it they are in windows registry? give me some api.
|
|
|
|
|
maybe this[^] will help
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Check GetModuleFileName in MSDN
...Plug & Pray...
|
|
|
|
|
Hi all,
I try to make simple program (from msdn sample) to encrypt data using Visual C++ 6, this is the program :
#include <wincrypt.h> // CryptoAPI definitions
#define MS_DEF_PROV "Microsoft Base Cryptographic Provider v1.0"
#define PROV_RSA_FULL 1
BOOL bResult;
HCRYPTPROC hProv;
// Attempt to acquire a handle to the default key container.
bResult = CryptAcquireContext(
&hProv, // Variable to hold returned handle.
NULL, // Use default key container.
MS_DEF_PROV, // Use default CSP.
PROV_RSA_FULL, // Type of provider to acquire.
0); // No special action.
// Release handle to container.
CryptReleaseContext(hProv);
but when I compile those codes, I get error messages like this :
error C2065: 'HCRYPTPROC' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'hProv'
error C2065: 'hProv' : undeclared identifier
error C2065: 'CryptAcquireContext' : undeclared identifier
error C2065: 'CryptReleaseContext' : undeclared identifier
I don't understand, these codes is very simple and I capture these codes from MSDN (so it must be success). Can anyone help me ?
Thanks
|
|
|
|
|
I know this sounds like a stupid question but you have included 'WinCrypt.h' haven't you?
I have not tried the code myself but normally this would be the first thing I would check.
You might also need to link against Advapi32.lib as well.
If I get chance then I will try and build the MSDN code and see why it does not work - but it looks like it's just the TYPSDEF's that it can't find - so try and include the header file and hopefully that should sort it out
Mark.
|
|
|
|
|
add following line b4 including "wincrypt.h"
#define _WIN32_WINNT 0x0400
greatest thing is to do wot others think you cant suhredayan@omniquad.com>
messenger :suhredayan@hotmail.com
|
|
|
|
|
yes, I have to define
#define _WIN32_WINNT 0x0400
before #include <wincrypt.h>
Thanks
|
|
|
|
|
In my edit control derived class I need to make it so that when the user hits the enter key that the control's focus is killed, how can I do that?
|
|
|
|
|
send the WM_KILLFOCUS message
|
|
|
|
|