|
Cool! What exactly did I win again ?
:-j
|
|
|
|
|
/*--------------------------------------------------------------*/
/*This function displays the captured bitmap in the window.It */
/*uses the palette of the captured bitmap so that colors are */
/*correct. */
/*--------------------------------------------------------------*/
void Paint(CDC* pDC,HPALETTE hPalette,HBITMAP hBitmap,LPRECT lpRect)
{
CDC * hDC;
CDC MemDC;
CPalette m_Palette;
CPalette * m_pPalette;
BITMAP bmInfo;
CBitmap m_Bitmap;
CBitmap *m_pBitmap;
hDC = pDC;
static int x=0;
//Get the BITMAP message of the hBitmap;
GetObject(hBitmap,sizeof(BITMAP),&bmInfo);
//Create the compatialbe bitmap for the m_Bitmap;
if(!m_Bitmap.CreateCompatibleBitmap(hDC,
(lpRect->right-lpRect->left),
(lpRect->bottom-lpRect->top)))
{
::MessageBox(NULL,"Error!","Error",MB_OK);
}
//Set the HBITMAP to the hBitmap;
if(m_Bitmap.FromHandle(hBitmap)==NULL)
{
::MessageBox(NULL,"Error--FromHandle!","Error",MB_OK);
};
if(MemDC.CreateCompatibleDC(hDC))
{
if(hPalette)
{
m_Palette.FromHandle(hPalette);
m_pPalette=(CPalette *)hDC->SelectPalette(&m_Palette,FALSE);
// RealizePalette(hDC);
}
m_pBitmap = (CBitmap *)MemDC.SelectObject(&m_Bitmap);
if(m_pBitmap==NULL)
{
::MessageBox(NULL,"Error--SelectObject!","Error",MB_OK);
}
int x=bmInfo.bmWidth;
int y=bmInfo.bmHeight;
//The flowing will occur a error.
//But i can't find out why.
if(!hDC->StretchBlt(lpRect->left,lpRect->top,
(lpRect->right-lpRect->left),
(lpRect->bottom-lpRect->top),
// &MemDC,0,0,x,
// y,SRCCOPY))
&MemDC,0,0,bmInfo.bmWidth,
bmInfo.bmHeight,SRCCOPY))
{
char tt[266],tmpstr[10];
char * p;
strcpy(tt,"Error--StretchBlt!");
p=_itoa(x,tmpstr,10);
strcat(tt,p);
::MessageBox(NULL,tt,"Error",MB_OK);
x=0;
}
else
{
x++;
}
// StretchBlt(hDC,ps.rcPaint.left,ps.rcPaint.top,
// (ps.rcPaint.right-ps.rcPaint.left),
// (ps.rcPaint.bottom-ps.rcPaint.top),
// hMemDC,0,0,bmInfo.bmWidth,
// bmInfo.bmHeight,SRCCOPY);
if(hPalette)
hDC->SelectPalette(m_pPalette,FALSE);
//Detect whether the CDC work.
// CBrush br(RGB(0,255,0));
// hDC->FillRect(lpRect,&br);
}
// EndPaint(hWnd,&ps);
}
This articles come from Code Project.
Thank you in advance!
|
|
|
|
|
I'd love to help, but it would be a lot easier if you posted the error you are getting. The StretchBlt call looks perfectly legal to me, so I need to know what error you are getting to look further.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
The flowing is my right code.
The cause of the error is that i call CreateCompatibleBitmap to create the compatible bitmap without the bmInfo.bmWidth and bmInfo.bmHeight.And there are other causes.
The right code is:
void Paint(CDC* pDC,HPALETTE hPalette,HBITMAP hBitmap,LPRECT lpRect)
{
CDC * hDC;
CDC MemDC;
CPalette m_Palette;
CPalette * m_pPalette;
CPalette * m_tmpPalette;
BITMAP bmInfo;
CBitmap m_Bitmap;
CBitmap *m_pBitmap;
CBitmap *m_tmpBitmap;
hDC = pDC;
static int xx=0;
//Get the BITMAP message of the hBitmap;
Sleep(1000);
GetObject(hBitmap,sizeof(BITMAP),&bmInfo);
//Create the compatialbe bitmap for the m_Bitmap;
if(!m_Bitmap.CreateCompatibleBitmap(hDC,
bmInfo.bmWidth,
bmInfo.bmHeight))
{
::MessageBox(NULL,"Error!","Error",MB_OK);
}
//Set the HBITMAP to the hBitmap;
if((m_tmpBitmap=m_Bitmap.FromHandle(hBitmap))==NULL)
{
::MessageBox(NULL,"Error--FromHandle!","Error",MB_OK);
};
if(MemDC.CreateCompatibleDC(hDC))
{
if(hPalette)
{
m_tmpPalette=m_Palette.FromHandle(hPalette);
m_pPalette=(CPalette *)hDC->SelectPalette(m_tmpPalette,FALSE);
}
m_pBitmap = (CBitmap *)MemDC.SelectObject(m_tmpBitmap);
if(m_pBitmap==NULL)
{
::MessageBox(NULL,"Error--SelectObject!","Error",MB_OK);
}
hDC->SetStretchBltMode(COLORONCOLOR);
if(!hDC->StretchBlt(lpRect->left,lpRect->top,
(lpRect->right-lpRect->left),
(lpRect->bottom-lpRect->top),
&MemDC,0,0,bmInfo.bmWidth,
bmInfo.bmHeight,SRCCOPY|DSTINVERT))
{
char tt[266],tmpstr[10];
char * p;
strcpy(tt,"Error--StretchBlt!");
p=_itoa(xx,tmpstr,10);
strcat(tt,p);
::MessageBox(NULL,tt,"Error",MB_OK);
xx=0;
}
else
{
xx++;
}
m_tmpBitmap->DeleteTempMap();
MemDC.SelectObject(m_pBitmap);
if(hPalette)
{
m_tmpPalette->DeleteTempMap;
hDC->SelectPalette(m_pPalette,FALSE);
}
}
}
This articles come from Code Project.
Thank you!
|
|
|
|
|
I need I SuperGrid. What is this ? A Grid that I can put some ComboBox in the cells, or a checkBox and something like this.
Does anybody have this supergrid ?
Thanks
|
|
|
|
|
Have you looked at Chris's Grid?
http://www.codeproject.com/miscctrl/
http://www.codeproject.com/miscctrl/gridctrl.asp
|
|
|
|
|
I have created an access db file using access and when I create an application with Class Wizard using DAO it reports that it doesn't recognize the file type. In ODBC it does however. The reason I wanted to use DAO is so that I can compact the database.
Any help would be appreciated, or how can I compact the database using ODBC.
Thanks in advance
Happy programming!!
|
|
|
|
|
G'day Wolfram,
What version of Access did you use to create the database?
If you used Access 2000, you might try converting the database
to an Access 97 format and see if that works.
Tools->Database Utilities->Convert Database
I've also had similar problems on occasions using DAO to open
an Access database, and I've found repairing the database
normally helps.
Hope this helps,
Steve
--------------------------------------
Steve Driessens
|
|
|
|
|
Sounds like a problem I had with 2000, there is a known issue.
Before you open the file add these two lines.
// These lines are required to access Access 2000 databases
AfxGetModuleState()->m_dwVersion = 0x0601;
AfxDaoInit();
If you search the MSDN site you will find the explaination.
http://support.microsoft.com/support/kb/articles/Q236/9/91.ASP
and
http://msdn.microsoft.com/library/periodic/period00/c++0100.htm
I added the above lines and it allows me to read both 97 and 2000 files.
I have not done much testing though.
|
|
|
|
|
Hi,
My application while starting is placed in the systray as a icon. When i double click the icon, i get a Dialog. If i execute my application again, i get one more icon in the systray and similarly if i double click the icon twice two dialogs appear on the screen. I want to have only one icon on the systray and even if i click the icon again ( ie double click ) it should show only the previous dialog and not the new one.
ie I want to have only one instance of my application at any time.
Can anybody help me in doing this.
Thanks in advance
VMJ
|
|
|
|
|
Hello,
In first line of InitInstance method of the Your application class, put the following code,
APP_NAME -- is the DialogWindow Title.
if(AfxGetMainWnd( )->FindWindow(NULL, APP_NAME))
{
AfxMessageBox("Application Already running");
exit(0);
}
If any suggesstions let me know.
Thanks ,
- Kannan.A.;)
|
|
|
|
|
Hello,
it works fine, but if you have open another window with the same name (e.g. explorer window or application with the same name) your application won't start.
Better way is to create some kernel object (MS suggest mutex) when your application starts and destroy at ending. Before creating you simply try to open such object and if succeded it means that your application is already running.
Regards
Bartek
|
|
|
|
|
I've created a class that's not an MFC one, its a graph that need to be refreshed in a concrete time lapse.
I would like to use a timer in that class, but I don't know how to do it:
SetTimer(...) asks for a window parameter or for a pointer to a function... Here is where I don't know how to continue.<
Could you give me some advice or help?
a little example would be great.
Thank you in advance.
|
|
|
|
|
If your graph class is derrived not from CWnd (thus not wrapping Windows window object - identified by HWND) you could call SetTimer(NULL, nIdEvent, uElapse, fnTimer), where fnTimer is a method from your graph class. What is important that you should declare this method as static (at compilation time you use its physical address - so compiler should know it ).
Regards
Bartek
|
|
|
|
|
This still won't work if you don't have a window. Timers require a message pump and window to operate, even the callback method.
More likely, what he wants is a either a waitable timer, or simply to use the Sleep function to wait a specific amount of time.
|
|
|
|
|
Yep - it's my fault ...
Hope Sleep() helps.
Regards
Bartek
|
|
|
|
|
Does anyone know of or have any similar code to creating a ticker of a song name or some string using iamages from a bitmap as your text.
Joshua
|
|
|
|
|
Hej Joshua.
This code is quite simple. All you have to do is prepare picture image (in resource editor) and write a procedure which will take a string as a parameter, traverse this string, compute offset of image corresponding to each letter and blit it. Simple, eh?
It remainds me old times - low level assembler procedures, demos, scrollers, vectors, amigas
Regards
Bartek
|
|
|
|
|
|
Suppose that you know make sounds, use this to manipulate the time:
The time in seconds is the value returned by the clock function, divided by CLOCKS_PER_SEC. CLK_TCK is equivalent, but considered obsolete.
#include <time.h>
#include <conio.h>
clock_t start, end;
void time_start()
{
start = clock();
}
int time_trans()
{
end = clock();
return((double)((end - start) / CLOCKS_PER_SEC) );
}
|
|
|
|
|
Hello,
I have a Cable/Dsl Linksys Router and was wondering how I could get the IP address it is using with the Internet provider. I know I can get it manually from the configuration but was wondering how it could be obtained programmatically.
Any thoughts will be appreciated.
Thanks,
Todd
|
|
|
|
|
This one goes out the ATL Wizards out there.
I need to wrap a MFC Window Class control inside an ATL Control.
I know I can subclass, I need to what the best method is.
Has any body done this kind of thing before, eg. Wrapping an Stingray GridWnd for instance
|
|
|
|
|
I am dealing list view ctr in dialog box, all is right i.e no error or warnig is ther but when I run the programm it gives "Unhandeled exception" message.
|
|
|
|
|
Hi Ali,
your description is too short to answer you. Your code is compiling correctly, but you have errors at run time (as I understood). One is certain - you are doing something wrong, but I can't help you Provide some more info ...
Regards
Bartek
|
|
|
|
|
Hello all.
I'am designing some application and I wish that end user could send an e-mail with some attachement by simple pressing button. I want to avoid him of being confused by configuring any connections.
I assume that user's machine has already configurated Internet connection (in most cases Dial-Up with modem) and E-mail client installed (in most cases MS Outlook).
So I see it working in this way: user clicks on a button and this action runs E-mail client - sets the recipient, message and attachement. User only has to press the Submit button (from e-mail client) (or even without - e-mail is sending automatically). The client optionally calls the Dial-Up connection to set up the connection.
I tried opening url ("mailto:xxx@yyy?subject=zzz"), but I cant figure how to set attachement and message body in this manner. So I looked into MAPI specyfication and implemented some sample. But there is a problem: after Submit action, even I have Lotus Notes and MS Outlook installed (LN is default client) I always see an screen to set up the profile. Bleee - this is the less expected thing I wanted to see ...
I dont know the MS Exchange technology well. Any help will by appreciated.
Similiar mechanism works fine in WinZip.
And sorry for my not always briliant english
Best regards
|
|
|
|
|