|
I want to exit an application programatically i will use
exit(0);
But some how i feel if i do this with MFC application, its not a good thing.
Can anyone tell me is it a safe way to exit an MFC application.
If any other approach is there plz let me know.
Thanks a lot
|
|
|
|
|
|
One can send WM_CLOSE message to the application
|
|
|
|
|
karmendra_js wrote:
Can anyone tell me is it a safe way to exit an MFC application.
PostQuitMessage(...);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi
I am using PostgreSQL as my Database. I have derived one Table using CRecordset. I have to use CByteArray to store Images into that table. I am using this way. is there any wrong in my code plz help me.
CCitizenPhoto rs;
rs.AddNew();
rs.m_sno = sno;
CFile f;
f.Open("Photo.jpg",CFile::modeRead);
rs.m_photo.SetSize(f.GetLength());
f.Read(rs.m_photo.GetData(),f.GetLength());
f.Close();
rs.SetFieldDirty(&rs.m_photo);
rs.SetFieldNull(&rs.m_photo,FALSE);
rs.Update();
rs.Close();
when i am running this code it is giving Error as Data Truncated.
I have Initialized MAXSIZE with 36000.
RFX_Binary(pFX,_T("[photo]",m_photo,MAXSIZE);
When i am storing of 10K image it is storing nicely and i am able to retrieve also. But more than 10k it is giving error as Data truncated. it is unable to store and retrive. both places giving error as Data truncated.
Plz help me
Thans in advance.
|
|
|
|
|
Hi! Does anyone know how can i make my application starts when windows starts up, i mean using code not put the application in the startup folder! . I think i must use the registry but i m not sure! Thanks!
------------------------------
If you can't find the
-- -- -- -- -- -- -- -- -- --
way..let the way find you..
------------------------------
|
|
|
|
|
extus wrote: Hi! Does anyone know how can i make my application starts when windows starts up, i mean using code not put the application in the startup folder!. I think i must use the registry but i m not sure! Thanks!
Try this :
CRegKey key;
LONG status = key.Open(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run");
if(status==ERROR_SUCCESS)
{
key.SetValue("Path of your program","Name of your program");
}
key.Close();
do not forget to include atlbase.h in your application
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 7:26 Saturday 15th October, 2005
|
|
|
|
|
sure ,you must set Registry
let your application start up after windows starts up
and use API function.
----------------------------
Jerry yu
Chinese
programming fans
|
|
|
|
|
extus wrote: i! Does anyone know how can i make my application starts when windows starts up, i mean using code not put the application in the startup folder!. I think i must use the registry but i m not sure! Thanks!
extus wrote: i! Does anyone know how can i make my application starts when windows starts up, i mean using code not put the application in the startup folder!. I think i must use the registry but i m not sure! Thanks!
In continuation With Giorgi:-
there are two more place from where you can start your application at window startup:-
#1 already told bu Giorgi
#2 HKEY_CURRENT_USER
code:- (just One change to Giorgi code)
CRegKey key;
LONG status = key.Open(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Run");
if(status==ERROR_SUCCESS)
{
key.SetValue("Path of your program","Name of your program");
}
key.Close();
#3 Make entry in %windir%\startup
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello everyone!
I want to debug my program, but When start the program need one
parameter, where can I input the parameter in VC7, please help
me!
Thank you very much!
|
|
|
|
|
For debugging purpose you can take variables instedof parameters
Madhu S. Kapoor
|
|
|
|
|
Right click on the project in Solution Explorer, click on Properties. Expand the treeview on the left and go to Configuration Properties->Debugging. Click on it and you'll find a textbox for entering "Command Arguments".
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thank you for your reply.
But in my program it doesn't work. I donn't know the reason.
if I run my program in command line as this: "XXXD.exe /Debug "
it run normally. But when I debug it in program,
I fill the debugging's Command :XXXD.exe, and fill the "Command Arguments": /Debug, but it run as : "XXXD.exe"
it seems the "Command Arguments" doesn't work , Perhaps there is
something I should to set ?
|
|
|
|
|
what program why not say the detail.
----------------------------
Jerry yu
Chinese
programming fans
|
|
|
|
|
int the function OnDraw(),I want to create a DIB bitmap using the array pData,but I am not successful,Please help me.
//the array containing color information
unsigned char* pData=new unsigned char[768*576];
int y=0, x=0;
for(;y<576;y++)
for(;x<768;x++)
{
pData[x*3+y*768*3]=0;
pData[x*3+1+y*768*3]=0;
pData[x*3+2+y*768*3]=255;
}
//information header
BITMAPINFOHEADER FrameBmi;
FrameBmi.biSize=sizeof(BITMAPINFOHEADER);
FrameBmi.biPlanes=1;
FrameBmi.biCompression=BI_RGB;
FrameBmi.biClrImportant=0;
FrameBmi.biSizeImage=768*576*3;
FrameBmi.biClrUsed=0;
FrameBmi.biBitCount=24;
FrameBmi.biWidth=768;
FrameBmi.biHeight=576;
FrameBmi.biXPelsPerMeter = 0;
FrameBmi.biYPelsPerMeter =0;
//file header
BITMAPFILEHEADER pf;
pf.bfType=0x4d42; //"BM"
pf.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(char[768*576]);
pf.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
pf.bfReserved1=0;
pf.bfReserved2=0;
//BITMAPINFOHEADER
LPBITMAPINFO lpbmi=(LPBITMAPINFO)GlobalAlloc(GMEM_FIXED,sizeof(BITMAPINFOHEADER));
ASSERT(lpbmi);
lpbmi->bmiHeader.biSize=FrameBmi.biSize;
lpbmi->bmiHeader.biPlanes=FrameBmi.biPlanes;
lpbmi->bmiHeader.biCompression=FrameBmi.biCompression;
lpbmi->bmiHeader.biClrImportant=FrameBmi.biClrImportant;
lpbmi->bmiHeader.biSizeImage=FrameBmi.biSizeImage;
lpbmi->bmiHeader.biClrUsed=FrameBmi.biClrUsed;
lpbmi->bmiHeader.biBitCount=FrameBmi.biBitCount;
lpbmi->bmiHeader.biWidth=FrameBmi.biWidth;
lpbmi->bmiHeader.biHeight=FrameBmi.biHeight;
lpbmi->bmiHeader.biXPelsPerMeter=FrameBmi.biXPelsPerMeter;
lpbmi->bmiHeader.biYPelsPerMeter=FrameBmi.biYPelsPerMeter;
lpbmi->bmiColors=NULL;
//创建DIB位图
CBitmap *OldBitmap;
HBITMAP bmp =::CreateDIBitmap((HDC)pDC,&FrameBmi,CBM_INIT,pData,lpbmi, DIB_RGB_COLORS);
ASSERT(bmp);
//
CBitmap bitmap;
bitmap.Attach(bmp);
CDC dcComp;
dcComp.CreateCompatibleDC(pDC);
OldBitmap=dcComp.SelectObject(&bitmap);
BITMAP bm;
bitmap.GetObject(sizeof(BITMAP),&bm);
// draw bitmap
pDC->BitBlt(0,0,768,576,&dcComp,0,0,SRCCOPY);
dcComp.SelectObject(OldBitmap);
delete [] pData;
GlobalFree(lpbmi);
help me!
|
|
|
|
|
I just got a lil confussed here.
I want to access a variable using the object of the class.
classXYZ objectname= new classXYZ();<br />
objectname.variablename=100;
so which access specifier is best for variablename.
Thanks.
|
|
|
|
|
If that code is outside classXYZ, you have no choice, it must be declared public.
Regards
Senthil
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
public : Accessible outside the class.
protected : Accessible to instances of the class, and to any classes derived from it.
private : Accessible only by the class itself.
Software Zen: delete this;
|
|
|
|
|
karmendra_js wrote:
I want to access a variable using the object of the class.
Accessing Class Variable outside class is not part of Good design.. always create Get and put function to access variable outside the class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I am writing a dilaogue based application where a memory bitmap is created and the OnPaint method does a BitBlt to the dialogue.
I can get it to work by doing an initial BitBlt at the end of the OnCreateBmp() method but I would rather trigger OnPaint() so there is no duplicate code. Several attempts at invalidating the client area haven't worked.
Any suggestions?
Elaine
OnCreateBmp()
{
...
pDC = this->GetDC();
m_MemBmp.CreateCompatibleBitmap(pDC,
m_ClientRect.Width(),
m_ClientRect.Width());
m_MemDC.SetTextColor(0xff00);
m_MemDC.TextOutA(33, 33, "Hello world");
}
bmp1Dlg::OnPaint()
{
...
pDC->BitBlt(m_ClientRect.left, m_ClientRect.top,
m_ClientRect.Width(),m_ClientRect.Height() ,&m_MemDC,0,0,SRCCOPY);
CDialog::OnPaint();
...
}
The tigress is here
|
|
|
|
|
call invalidaterect at then end of the OnCreateBmp
-prakash
|
|
|
|
|
That was my first attempt as the last line in OnCreateBitmap:
InvalidateRect(m_ClientRect, TRUE); but it makes no difference.
The tigress is here
|
|
|
|
|
try InvalidateRect(NULL, TRUE);
-prakash
|
|
|
|
|
From where does OnCreateBmp get called? Maybe it's called before GetClientRect can actually get the size of the client rectangle?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
OnCreateBmp is a button event and m_ClientRect is set up within OnCreateBmp.
As I said if I put a copy of the BitBlt at the end of OnCreateBmp everything is fine, I am simply trying to get the OnPaint to happen and avoid duplicating code.
The tigress is here
|
|
|
|