|
I have double checked this.
The command ID_VIEW_DRAWTOOLBAR is not used anywhere in the project except for calling the handler OnDrawToolBar and update handler OnUpdateDrawToolBar in the mainframe
laiju
|
|
|
|
|
Wild guess, but I'd check if ID_VIEW_DRAWTOOLBAR happens to be defined with the same number as some other command...
Otherwise, I suggest setting a breakpoint in CMDIFrameWnd::OnCmdMsg() (it's in MFC's winmdi.cpp) with a condition (nID==ID_VIEW_DRAWTOOLBAR) and following the execution from there through the debugger to see how the message is routed and where it's being handled.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
hi
i had made an application in visuall c++, which counts the numners of text files in drive c.i want to asssociate with the web page. somebody told me that u make the active X control link it to the web page.
my question is how to link the web page with active X control and can i use the MFC activex control wizard to make the such active x control.
ddd
|
|
|
|
|
http://www.download.com/ActiveX-Control-Pad/3000-2406_4-861343.html
|
|
|
|
|
Hi,
I am new to MFC and Windows Service. I am trying write a Windows Service Program, its job is to take Screen Capture once in while and save it as a bitmap. For this I am using BitBlt() function. It is failing with "Invalid Handle", but I checked all the handles and they are valid.
I used same code to capture screen which uses BitBlt in a normal Windows apllication and it is working fine.
So , BitBlt is only failing in Windows Service.
Please help me to resolve this issue.
Thanks
VV
|
|
|
|
|
Please post some code. There are so many articles on capturing the sceen that it will probably be nothing new. It may be just a minor mistake in the code.
The smaller the example the better.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
vegeakhil wrote:
I am trying write a Windows Service Program, its job is to take Screen Capture once in while and save it as a bitmap
Is your service is DESKTOP INTERECTIVE SERVICE? if not, you always get BLANK IMAGE or Invalid HANDLE
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Yes, the service is created with SERVICE_INTERACTIVE_PROCESS property. Give me some more time I will post the code also. Thanks
|
|
|
|
|
The same Screen Capture function is working fine if I call from simple application (normal application not a service application). So I am thinking it is something to do with service.
|
|
|
|
|
Hi Guys
Pls help me...the code is , just to remind you again, if I call this function from simple application it is fine, but if I call from windows service, BitBlt is failing with "Invalid Handle".
Thanks
BOOL CFrameBuffer::CaptureScreen(CRect rectScreen, BYTE *scrBuff)
{
HBITMAP hDesktopCompatibleBitmap=NULL;
HDC hDesktopCompatibleDC=NULL;
HDC hDesktopDC=NULL;
HWND hDesktopWnd=NULL;
int nHeight=rectScreen.bottom-rectScreen.top;/GetSystemMetrics(SM_CXSCREEN);
int nWidth=rectScreen.right-rectScreen.left;//GetSystemMetrics(SM_CYSCREEN);
hDesktopWnd=GetDesktopWindow();
hDesktopDC=::GetDC(NULL);
hDesktopCompatibleDC=CreateCompatibleDC(hDesktopDC);
hDesktopCompatibleBitmap=CreateCompatibleBitmap(hDesktopDC,nWidth,nHeight);
BOOL bRet = FALSE;
HBITMAP oldbitmap;
oldbitmap = (HBITMAP)SelectObject(hDesktopCompatibleDC,hDesktopCompatibleBitmap);
if(hDesktopCompatibleDC && hDesktopDC)
{
bRet = BitBlt(hDesktopCompatibleDC,0,0,nWidth,nHeight,hDesktopDC,0,0,SRCCOPY);
}
OPENFILENAME ofn;
char szFileName[512]; szFileName[0]='\0';
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize=sizeof(OPENFILENAME);
ofn.Flags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;
ofn.lpstrFilter="Bitmap Files (*.bmp)\0*.bmp\0";
ofn.lpstrDefExt="bmp";
strcpy(szFileName,"C:\\temp\\MyBitmap.bmp");
ofn.lpstrFile=szFileName;
ofn.nMaxFile=512;
CFileFind finder;
if(finder.FindFile(szFileName))
{
DeleteFile(szFileName);
}
SetCursor(LoadCursor(NULL,IDC_WAIT));
BITMAPINFO bi;
void *pBits=NULL;
ZeroMemory(&bi,sizeof(bi));
bi.bmiHeader.biSize=sizeof(bi.bmiHeader);
bi.bmiHeader.biHeight=nHeight;
bi.bmiHeader.biWidth=nWidth;
bi.bmiHeader.biPlanes=1;
bi.bmiHeader.biBitCount=32;//16 bit
bi.bmiHeader.biCompression=BI_RGB;
bi.bmiHeader.biSizeImage=nWidth*nHeight *sizeof(DWORD);
bi.bmiHeader.biHeight = abs(nHeight);
HDC hBmpFileDC=CreateCompatibleDC(hDesktopCompatibleDC);
HBITMAP hBmpFileBitmap=CreateDIBSection(hDesktopCompatibleDC,&bi,DIB_RGB_COLORS,&pBits,NULL,0);
SelectObject(hBmpFileDC,hBmpFileBitmap);
BitBlt(hBmpFileDC,0,0,nWidth,nHeight,hDesktopCompatibleDC,0,0,SRCCOPY);
HANDLE hFile=CreateFile(szFileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile!=INVALID_HANDLE_VALUE)
{
DWORD dwRet=0;
BITMAPFILEHEADER bmfHeader;
ZeroMemory(&bmfHeader,sizeof(bmfHeader));
bmfHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
bmfHeader.bfSize=bi.bmiHeader.biSizeImage+bmfHeader.bfOffBits;
bmfHeader.bfType='MB';
WriteFile(hFile,&bmfHeader,sizeof(bmfHeader),&dwRet,NULL);
WriteFile(hFile,&bi.bmiHeader,sizeof(bi.bmiHeader),&dwRet,NULL);
WriteFile(hFile,pBits,bi.bmiHeader.biSizeImage,&dwRet,NULL);
CloseHandle(hFile);
AddToMessageLog(" Inside 2 CaptureScreen() is called", 1 );
}
if(scrBuff!=NULL)
{
memcpy(scrBuff,pBits,bi.bmiHeader.biSizeImage);
}
SelectObject(hDesktopCompatibleDC,oldbitmap);
DeleteDC(hBmpFileDC);
DeleteObject(hBmpFileBitmap);
ReleaseDC(hDesktopWnd,hDesktopDC);
return TRUE;
}
|
|
|
|
|
How do i create a function which accepts the same parameters as printf(...)?
In stdio.h, printf is declared as
_CRTIMP int __cdecl printf(const char *, ...); I tried creating a similar function
void test(const char *pStr, ...)
{
printf(pStr);
} However, test(...) display differently from the actual printf(...) call. What am i missing?
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
The ... represents a parameter collection of unknown size. Zero is an acceptable size, so your code ends up calling successfully, but gives printf nothing to do.
This[^] took me ages to find, none of the words I was searching on was specific enough to avoid a thousand hits to basic C++ pages, as ... appears all over the place.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for the link. It certainly explains some 'behind the scene' stuff.
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
The fuction below represents that last time I remember having to do this:
int my_printf( const char *format,... )
{
int n=-1;
char *buf=NULL;
size_t size=0;
va_list ap;
va_start( ap,format );
while( n == -1 ) {
size += 128;
if( buf ) free(buf);
buf = (char *)malloc(size);
if( !buf ) n = 0;
else n = _vsnprintf(buf,size,format,ap);
}
va_end(ap);
my_print(buf);
return n;
}
The _vsnprintf() function is still supported by VC6, so it still works. The key is the va_list(), va_start() and va_end() (macros I believe). You'll need to look them all up and may be bring them upto date (this was written around 1992).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Thanks. Your code works just like printf. Now i need to see if this would run well on unix.
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
|
Thanks for the links. I should have search the articles section first.
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
Very new to c++.
I need to extract specific data from a comma delimited file and then and created a new comma delimited file with the extracted data.
Help is appreciated
Thanks
Joe M
|
|
|
|
|
This makes no since (it would be simple to do your self), but someone at MS thought differently.
CopyFile() or CopyFileEx().
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
i want to apply ado to access database. i put following in my stdafx.h
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "adoEOF")
but when i compile ,there are "error C2011: 'LockTypeEnum' : 'enum' type redefinition".
what should i change no_namespace into?
|
|
|
|
|
the bit at the end that says rename ("EOF", "adoEOF") could possibly also be used to rename LockTypeEnum ( I don't know for sure ). Or you could check where the clash is and fix it at the other end ( the other place that defines LockTypeEnum ). Or you can remove it entirely, which means that ADO will be imported within a namespace.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a linked list each node of it hase (name,phone....)
I want to sort it by name
struct PhoneBookEntry
{
CString Name,Email,Website,Adress;
CString OfPhone,HoPhone,Mobile;
};
typedef CList<phonebookentry *,="" phonebookentry="" *=""> PhoneBook;
PhoneBookEntry* InputEntry()
{
PhoneBookEntry* pEntry = new PhoneBookEntry;
cout << " Enter New Contact Details:" << endl;
cout << " Name : ";
char cName[100];
gets(cName);
return pEntry;
}
void main()
int nChoice
switch (nChoice)
{
case 1: // add contact
PhoneBookEntry *pEntry;
pEntry = InputEntry();
g_PhoneBook.AddTail(pEntry);
break;
case 2: // list entries
pos = g_PhoneBook.GetHeadPosition();
while (pos)
{
PhoneBookEntry* pEntry = g_PhoneBook.GetNext(pos);
PrintEntry(pEntry);
}
break;
|
|
|
|
|
|
how can I switch to std::list, and use std::sort. ??!
I didnt understand.....sorry
|
|
|
|
|
The list container is part of the STL.
Simple sort example:
<br />
#include "stdafx.h"<br />
<br />
#include <list><br />
#include <algorithm>
<br />
bool sortAscending(int a, int b)<br />
{<br />
return (a < b);<br />
}<br />
<br />
bool sortDescending(int a, int b)<br />
{<br />
return (b < a);<br />
}<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
std::list<int> myList;<br />
<br />
myList.push_back(2);<br />
myList.push_back(1);<br />
myList.push_back(4);<br />
<br />
std::cout << "Before sort" << std::endl;<br />
for (std::list<int>::iterator i = myList.begin(), iEnd = myList.end();<br />
i != iEnd; ++i)<br />
{<br />
std::cout << (*i) << std::endl;<br />
}<br />
<br />
myList.sort(sortAscending);<br />
<br />
std::cout << "Ascending sort" << std::endl;<br />
for (std::list<int>::iterator i = myList.begin(), iEnd = myList.end();<br />
i != iEnd; ++i)<br />
{<br />
std::cout << (*i) << std::endl;<br />
}<br />
<br />
myList.sort(sortDescending);<br />
<br />
std::cout << "Descending sort" << std::endl;<br />
for (std::list<int>::iterator i = myList.begin(), iEnd = myList.end();<br />
i != iEnd; ++i)<br />
{<br />
std::cout << (*i) << std::endl;<br />
}<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|