|
And what was your code?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
If you are using CBitmap to load your bitmap in MFC, you can get the whole bitmap pixel array using GetBitmapBits in to your own byte* buffer. To access any particular scanline, you can use the formula of X*B+Y*W*B, X is your x coordinate, Y is your Y coordinate, W is your image width (you can obtain this from CBitmap) and B is your bitdepth of the image in bytes.
|
|
|
|
|
I still could not solve th problem.I am not using MFC , only sdk.
what I am doing i am copying the "myfilename.bmp" image buffer
to some other buffer. i store a pointer to the starting address of the pixel bits in
BYTE * m_pImage;
Now I want to get scanline buffer up to the bitmap height-1.
so I still confused how to get scanline up to bitmap height-1.
Trioum
|
|
|
|
|
Hi All,,
I am making the Windows Service with the help VC++. I want to perform the some tasks like capture desktop screen from the service.For that I have writen below code which gives unwanted result.
<br />
<br />
void SendCapturedScreen()<br />
{<br />
FILE *f;<br />
f = fopen("E:\\CaptureLog.txt","w");<br />
char *str = (char *)malloc(2000);<br />
<br />
RECT rect;<br />
<br />
rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN);<br />
rect.top = GetSystemMetrics(SM_YVIRTUALSCREEN);<br />
rect.right = rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);<br />
rect.bottom = rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN);<br />
<br />
m_hrootdc = ::GetDC(NULL);<br />
m_hmemdc = CreateCompatibleDC(m_hrootdc);<br />
<br />
int iWidth = rect.right - rect.left;<br />
int iHeight = rect.bottom - rect.top;<br />
<br />
HBITMAP new_Bitmap = CreateCompatibleBitmap(m_hrootdc,iWidth,iHeight);<br />
HBITMAP temp_Bitmap = (HBITMAP)SelectObject(m_hmemdc,new_Bitmap);<br />
if(temp_Bitmap == NULL)<br />
{<br />
sprintf(str,("Failed to get HBITMAP from SelectObject"));<br />
fwrite(str,strlen(str),1,f);<br />
}<br />
<br />
BOOL blitok = BitBlt(<br />
m_hmemdc, <br />
0,<br />
0,<br />
rect.right - rect.left,<br />
rect.bottom - rect.top,<br />
m_hrootdc,<br />
rect.left, rect.top,<br />
SRCCOPY);<br />
<br />
int err = GetLastError();<br />
<br />
if(blitok)<br />
{<br />
sprintf(str,("\nBitBlt Successed\nError Code:%d"),err);<br />
fwrite(str,strlen(str),1,f);<br />
}<br />
else<br />
{<br />
sprintf(str,("\nBitBlt Failed\nError Code:%d"),err);<br />
fwrite(str,strlen(str),1,f);<br />
}<br />
<br />
Here what happens I dont get the BitBlt function's success. It fails and the GetLastError() function returns the code no 6 means invalid handle.So I want to ask you form the service I can not perform this operation. And I also check that both handles are not null.
Plz give any suggesion you have.
Thanks in Advance.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
See does this code helpful
HDC m_hdcMem,hdc;
HBITMAP m_Bitmap,m_OldBitmap,hMainBmp;
hdc=GetDesktopWindow()->GetDC()->m_hDC;
m_Bitmap = CreateCompatibleBitmap(hdc,800,600);
m_OldBitmap=(HBITMAP) SelectObject(m_hdcMem, m_Bitmap);
BitBlt(m_hdcMem, 0,0,800,600, hdc,0,0,SRCCOPY);
hMainBmp =(HBITMAP) SelectObject(m_hdcMem, m_OldBitmap);
CImage m_Image;
m_Image.Attach(hMainBmp);
m_Image.Save("c:\\test.bmp");
m_Image.Destroy();
DeleteDC(m_hdcMem);
DeleteObject(hMainBmp );
DeleteObject(m_OldBitmap);
|
|
|
|
|
Thank You very much for reply.
First of all I can not execute below line of code in my application as shown ,it gives errors.
<br />
hdc=GetDesktopWindow()->GetDC()->m_hDC;<br />
And I also want to tell you that when I use m_hrootdc variable in the place of m_hmemdc in the function BitBlt() (Look into code which I posted before) then it does not show error but also it does not show bitmap on the screen.
Is these all about service which does not allow the UI interface or anything else.
Any more Ideas??
Thanks.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
I have just tried your code in a normal application and it is working.
I am not familar with service.
But at the least can you find out which handle is invalid?
I think using BitBlt with
BOOL blitok = BitBlt( m_hmemdc, 0, 0, 100, 100, 0, 0, 0, WHITENESS ); // Check m_hmemdc
and
BOOL blitok = BitBlt( m_hrootdc, 0, 0, 100, 100, 0, 0, 0, WHITENESS ); // Check m_hrootdc
will helpful.
|
|
|
|
|
Thanks for Reply.
As you told to check both handles, I did the same and also got both handles right. In both cases it did not show invalid handle.
But I checked other thing that I tried to display some pixels using SetPixel() function but I did not get success.So ,finaly I conclude that service does not allow the interaction with desktop.
So I tried to make it able to interact with desktop from service property but itr still gives that error that handle is not valid. Do you know how can I interact with desktop through service?
Do you have any other suggetion??
Thanks.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
ashishbhatt wrote: As you told to check both handles, I did the same and also got both handles right. In both cases it did not show invalid handle.
ashishbhatt wrote: But I checked other thing that I tried to display some pixels using SetPixel() function but I did not get success.
I got confused, because you can call BitBlt with WHITENESS with success.
|
|
|
|
|
Now I realy got the problem for what this problem occurs.
This is the problem of service which runs in its own desktop session, so it will not allow any user to interact with the desktop.
I made different application to capture desktop and tried to run that exe frm the service but the same problem occurs means this is the probelm of service.
But now the problem is that when i allow the service to run with interaction with user desktop then also it gives the same error. .I set this option from servcie property and Logon Tab.
Do you have any Idea about this problem??
Thanks for taking interest.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
ashishbhatt wrote: Do you have any Idea about this problem??
I am sorry, I am not familar with service.
What happened when BitBlt( m_hrootdc, 0, 0, 100, 100, 0, 0, 0, WHITENESS ); is called?
If I do it from a normal application, it will paint a white solid filled rectangle on the desktop. Does the same happen in the service? If so then we can say we can operate on desktop dc.
|
|
|
|
|
But it did not happen with case of service.So it means it does not allow the desktop interaction.
So, do have any more idea then reply me.
You answer will be appreciated.
Ashish Bhatt,
System Developer,
Avinashi System Pvt. Ltd.
|
|
|
|
|
|
how to take the path dynamically when connecting to the database using SQLConfigDataSource function.
Here is my actual code.
int m_retcode=SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)","DSN=dbCustomer\0""DBQ=E:\\Others_Cp\\DKK\\examples\\CDatabase\\db.mdb\0");
if(m_retcode!=TRUE)
AfxMessageBox("Connection Failed");
else
AfxMessageBox("coonection succed");
I need to get this path dynamically.but when i am using this connection is not establishing.
Char *str;
str="DSN=dbCustomer\0""DBQ=E:\\Others_Cp\\DKK\\examples\\CDatabase\\db.mdb\0";
int m_retcode=SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)",str);
if(m_retcode!=TRUE)
AfxMessageBox("Connection Failed");
else
AfxMessageBox("coonection succed");
In the above case connection is establishing but i am not getting the path of the database table.
How to get this one?
viritha
|
|
|
|
|
|
I have a class A with private members.
I create a new class the implements a functions that takes a pointer to a class A object,
and works with it's private members.
for that I define the member function as friend in class A in the following manner:
#include"BankAccount.h"
class Teller
{
public:
float checkAccount(BankAccount *bap);
};
#include"Teller.h"
class BankAccount
{
friend class BankManager;
friend float Teller::checkAccount(BankAccount* bap);
private:
float sum;
short code;
public:
BankAccount(short _code);
BankAccount(short _code, float _startSum);
float getSum(short _code);
void deposit(float _amount);
void withdraw(short _code, float _amount);
};
the problem is that I receive the following errors:
error C2061: syntax error : identifier 'BankAccount'
error C2245: non-existent member function 'Teller::checkAccount' specified as friend (member function signature does not match any overload)
what am I doing wrong???
thanks for your help.
|
|
|
|
|
Looks like circular includes...maybe this will work better...
class BankAccount;
class Teller
{
public:
float checkAccount(BankAccount *bap);
};
#include"Teller.h"
class BankAccount
{
friend class BankManager;
friend float Teller::checkAccount(BankAccount* bap);
private:
float sum;
short code;
public:
BankAccount(short _code);
BankAccount(short _code, float _startSum);
float getSum(short _code);
void deposit(float _amount);
void withdraw(short _code, float _amount);
};
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
no it didn't help;
still I get the "use of undefined type BankAccount" Error.
any other suggestion.
|
|
|
|
|
It works for me as shown.
You should only get that error if the compiler doesn't know
the BankAccount when the class is referenced. Without seeing
the exact code that's not failing, I don't know
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How to save image in sqlserver with VC++6?
adamichopirgashthersjavanmigardad
|
|
|
|
|
How are you accessing the database? C++ framework? APIs?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
To save images in datbase Sql Sever introduced new Datatype BLOB.
You need to search for manipulation of BLOB in VC6.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Hello to all, and thanks for helping.
My question is something like this:
Say I have a function in a base class that prints the value of two of it's members.
Now I go and create a derived class from the base class the has one more member on top of the two it inherits from the base.
and lets say the function name is show().
How, from the implementation of the derived do I call the implemetation from the base, to save code duplicating?????
class base
{
int a;
int b;
void show(){cout << a << b;}
};
class derived
{
int c;
void show()
{
....;
cout << c;
}
};
what goes instead of the ....; line???
again thanks for your help
|
|
|
|
|
gizmokaka wrote: what goes instead of the ....; line???
base::show();
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
I did that before and it didn't work for some weird reason so I did this->base::show()
and now that I tried again after you said, it did work.
Funny how things work (probably wrote bad syntax before).
Any way on the same note.
How do I call the base constructor from the derived c'tor?
if:
class base
{
base(int a, int b)
{
x = a;
y = b;
}
};
class derived
{
derived(int a, int b, int c):z(c)
{
how to call base c'tor with a and b ????
or maybe it's also done in the initialization list???
}
};
|
|
|
|
|