|
I've googled this Usenet article[^] down, which does the trick by simulating the ALT-ENTER keystrokes. It is Delhpi, but easily translatable to C++.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Cheers, I'd already found a fake Alt Enter sequence on another site. But thanks anyway
"werewnt we going to run off and start a convent on as islandf]" -David Wulff, again on MSN while plastered...
Jonathan 'nonny' Newman
Homepage [www.nonny.com] [^]
Bob Chum Dev site [^]
|
|
|
|
|
I posted this problem before, but no one can help me...plz it's urgent!
Hi, in my MFC app I have a template class like this:
<br />
template < class BASE ><br />
class CBWnd : public BASE {<br />
public:<br />
CBWnd(){};<br />
CBWnd(LPCTSTR s, CWnd *p):BASE(s, p){};<br />
CBWnd(UINT n, CWnd *p):BASE(n, p){};<br />
CBWnd(LPCTSTR s):BASE(s){};<br />
CBWnd(UINT n):BASE(n){}; <br />
};<br />
When I derive a class from an MFC one a make this:
<br />
class CMyButton : public CBWnd < CButton > {};<br />
<br />
class CMyDialog : public CBWnd < CDialog > <br />
{<br />
CMyDialog(LPCTSTR s, CWnd *p):CBWnd< CDialog >(s, p){};<br />
};<br />
In the contructors of CMyButton and CMyDialog I need to pass the parameters (for example the template ID and the parent window of derived a dialog) to the base class (CDialog, CButton and so on...that's why all constructors).
This code works fine on Visual Studio 6 but doesn't compile on Visual Studio 2003 because this compiler check all the CBWnd constructors (VS6 check only the used ones...)and if there isn't an implementation in the other classes (CMyButton, CMyDialog ecc...)
of the called one it generates an error...
Plz help me!
|
|
|
|
|
What is an error?
When I look into yours CBWnd(LPCTSTR s, CWnd *p):BASE(s, p){}; I see it should be failing on CButton -- CButton doesn't have CButton(s, p) constructor overload...
|
|
|
|
|
Ummm... I don't have a MSVC 7.0 compiler handy, but what you say seems like a gross bug in it --only actually called member functions should be instantiated. It'd be great if you could reproduce the error in a simple program (hopefully, whitout any MFC mess, just bare classes and constructors).
In the meantime, you can try the following:
template <class BASE>
class CBWnd : public BASE {
public:
CBWnd(){};
template <typename T0> CBwnd(const T0& t0):BASE(to){}
template <typename T0,typename T1> CBwnd(const T0& t0,const T1&t1):BASE(t0,t1){}
template <typename T0,typename T1,typename T2> CBwnd(const T0& t0,const T1& t1,const T2& t2):BASE(t0,t1,t2){}
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
From my MFC program I want to pipe XML data to the internet explorer. To make it clear, if I press a button an Internet Explorer window will pop up and where I'll show the XML generated from my program.
How do I do that?
Please help
Binayak
|
|
|
|
|
You don’t necessarily have to directly integrate your program with IE to display XML. One solution is to write the XML data into a file. Then start the iexplore.exe process and give it the filename of your XML file as a parameter. IE will come up with your XML data displayed.
Lorenz Prem
Microsoft Corporation
|
|
|
|
|
I just finished writing a class which should allow you to use a CArchive with a CBlockingSocket class. The same way CArchive works with CSocket, except this one is built on CBlockingSocket which doesn't implement 16-bit functions like CSocket.
Has anyone else tried this or have any knowledge on it? If so, are there any caviates with doing it this way? I've posed my code below for your paruzal:
The class name is CBlockingSocketFile and it emulates functionality in a CFile object. Basically so you can serialize to a CArchive and have it be transmitted across TCP/IP.
Here's the header file:
#define BLOCK_SOCK_TIMEOUT 15
class CBlockingSocketFile : public CFile
{
DECLARE_DYNAMIC(CBlockingSocketFile)
public:
CBlockingSocketFile(CBlockingSocket *pNewSocket);
virtual ~CBlockingSocketFile();
public:
CBlockingSocket * pSocket;
virtual UINT Read(void * pBuffer, UINT nBytes);
virtual void Write(const void* pBuffer, UINT nBytes);
virtual void Close();
private:
virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL);
virtual CFile* Duplicate() const;
virtual DWORD GetPosition() const;
virtual LONG Seek(LONG lOff, UINT nFrom);
virtual void SetLength(DWORD dwNewLen);
virtual DWORD GetLength() const;
virtual void LockRange(DWORD dwPos, DWORD dwCount);
virtual void UnlockRange(DWORD dwPos, DWORD dwCount);
virtual void Flush();
virtual void Abort();
};
And here's the source file:
IMPLEMENT_DYNAMIC(CBlockingSocketFile, CFile);
CBlockingSocketFile::CBlockingSocketFile(CBlockingSocket *pNewSocket)
{
if(pNewSocket == NULL) {
DEBUG_LOG("CBlockingSocketFile constructor: NULL pointer assignment.");
AfxThrowUserException();
}
pSocket = pNewSocket;
}
CBlockingSocketFile::~CBlockingSocketFile()
{
}
UINT CBlockingSocketFile::Read(void *pBuffer, UINT nBytes)
{
return pSocket->Receive((char *)pBuffer, (const int)nBytes, BLOCK_SOCK_TIMEOUT);
}
void CBlockingSocketFile::Write(const void *pBuffer, UINT nBytes)
{
pSocket->Write((const char*)pBuffer, (const int)nBytes, BLOCK_SOCK_TIMEOUT);
}
void CBlockingSocketFile::Close()
{
pSocket->Close();
}
BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL)
{
return false;
}
CFile* Duplicate(){return NULL;}
DWORD GetPosition(){return 0;}
LONG Seek(LONG lOff, UINT nFrom){return 0;}
void SetLength(DWORD dwNewLen){}
DWORD GetLength(){return 0;}
void LockRange(DWORD dwPos, DWORD dwCount){}
void UnlockRange(DWORD dwPos, DWORD dwCount){}
void Flush(){}
void Abort(){}
Any input would be much appreciated
Mike Ellertson
|
|
|
|
|
he he, ok I'm embarrased. I had the first code post jacked up... fault slip of the mind
Here's the corrected source file:
IMPLEMENT_DYNAMIC(CBlockingSocketFile, CFile);
CBlockingSocketFile::CBlockingSocketFile(CBlockingSocket *pNewSocket)
{
if(pNewSocket == NULL) {
DEBUG_LOG("CBlockingSocketFile constructor: NULL pointer assignment.");
AfxThrowUserException();
}
pSocket = pNewSocket;
}
CBlockingSocketFile::~CBlockingSocketFile()
{
}
UINT CBlockingSocketFile::Read(void *pBuffer, UINT nBytes)
{
return pSocket->Receive((char *)pBuffer, (const int)nBytes, BLOCK_SOCK_TIMEOUT);
}
void CBlockingSocketFile::Write(const void *pBuffer, UINT nBytes)
{
pSocket->Write((const char*)pBuffer, (const int)nBytes, BLOCK_SOCK_TIMEOUT);
}
void CBlockingSocketFile::Close()
{
pSocket->Close();
}
BOOL CBlockingSocketFile::Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError){ return false; }
CFile* CBlockingSocketFile::Duplicate() const {return NULL;}
DWORD CBlockingSocketFile::GetPosition() const {return 0;}
LONG CBlockingSocketFile::Seek(LONG lOff, UINT nFrom){return 0;}
void CBlockingSocketFile::SetLength(DWORD dwNewLen){}
DWORD CBlockingSocketFile::GetLength() const {return 0;}
void CBlockingSocketFile::LockRange(DWORD dwPos, DWORD dwCount){}
void CBlockingSocketFile::UnlockRange(DWORD dwPos, DWORD dwCount){}
void CBlockingSocketFile::Flush(){}
void CBlockingSocketFile::Abort(){}
Mike Ellertson
|
|
|
|
|
Hi
When i insert component like the MicrosoftBrowser, the studio automatically creates a wrapper class for the control, and in this wrapper class there is a function call:
CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID)
does anyone know what this does? Since i would like to implement this in pure win32api without any intervention from Microsoft Visual studio or wizard! Any constructive suggestion are highly appreciated.
Regard,
|
|
|
|
|
I want get a associated icon from a file system (for example c:\test.doc") using SHGetFileInfo function and save it in a file (for ex "C:\myicon.ico").
But GlobalSize and GlobalLock returns 0 (invalid value!!!).
I've read an IconPro example (in vs6example.exe) but I didn't found a good solution!
Please give me a good idea!
Tnk you
/******MY CODE*****/
CString nomefile = "c:\\test.doc";
HICON hGen32Icon;
HIMAGELIST hSysImageList;
SHFILEINFO shfi;
int fh;
UINT uiSize;
DWORD dwSize;
LPVOID lpGMem;
OFSTRUCT of;
hSysImageList = (HIMAGELIST)SHGetFileInfo
(nomefile,
0,
&shfi,
sizeof (SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
hGen32Icon = ImageList_GetIcon (hSysImageList,
shfi.iIcon,
ILD_NORMAL);
dwSize = GlobalSize(hIcon); /*Don't work*/
lpGMem = GlobalLock(hIcon); /*Don't work*/
fh = OpenFile ("c:\\myicon.ico", &of, OF_WRITE | OF_CREATE);
if (fh == -1) // If NOT opened successfully.
{
MessageBox("Unable to create file", NULL, MB_OK );
}
uiSize = _lwrite(fh, (LPSTR)lpGMem, (UINT)dwSize);
_lclose(fh);
|
|
|
|
|
Enza wrote:
dwSize = GlobalSize(hIcon); /*Don't work*/
lpGMem = GlobalLock(hIcon); /*Don't work*/
What is hIcon ? I assume this is supposed to be hGen32Icon . GlobalSize() is probably failing because hGen32Icon is not a global variable memory object.
|
|
|
|
|
sorry, the HICON is hGen32Icon...
How I can declare a global variable memory object?
tnk
|
|
|
|
|
I have software that "Commits" 2KB with every call to fopen(). I have tried the following with the following results:
<br />
<br />
if (fp = fopen(filename, "cwt"), fp != NULL)<br />
{<br />
}<br />
else<br />
perror( ... );<br />
<br />
<br />
<br />
if (h = _open(filename, _O_CREAT|_O_TRUNC|_O_WRONLY|_O_TEXT), h != -1)<br />
{<br />
}<br />
else<br />
perror( ... );<br />
<br />
Any thoughts? Thanks ...
|
|
|
|
|
jmf314159 wrote:
if (fp = fopen(filename, "cwt"), fp != NULL)
{
What is this??
I'd like to think the majority of people would write:
if ( (fp = fopen(filename, "cwt")) != NULL )
open/fopen etc. will fail if the file is marked r/o and you are trying to write to it or create it. Or if the file is locked by another process, or the path is invalid etc. You can test errno for specific details of the error.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Thanks for telling me what you would like to think.
I thought I had made clear that ...
(a) the anomaly was induced by the addition of the 'c' switch, and
(b) perror(), which maps errno to text, reported "no error" even though fopen() returned NULL.
This suggests that the problem was not file attributes, file locking, and/or file specification, and that further interrogating errno would achieve little. Thanks anyway.
|
|
|
|
|
jmf314159 wrote:
Thanks for telling me what you would like to think.
Its comments like this that realy make me wonder why I spend time trying help my fellow programmers sometimes.
"c" can't be the first character in the mode string. A quick bit of digging showed this.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
Its comments like this that realy make me wonder why I spend time trying help my fellow programmers sometimes.
... because most of your fellow programmers are good guys, like you... and then there are exceptions
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
|
|
|
|
|
Try using C or C++ and you might have more luck...
|
|
|
|
|
I'd like to add some nice effects in my SDI-Application. But which message do I have to handle or in which function do I have to add my own code?
I tryed to handle the ID_APP_EXIT from the menubar. But when I use my own code for this, the window won't close and I don't know how to close it manually...(and this also doesn't work for the close-shortcut in the upper-right (the x))
Tryed PostMessage((HWND)m_pMainWnd,WM_CLOSE,NULL,NULL); but this doesn't work either
btw. how can I get the code for such compiler-made functions like closing the windows, minimizing and all that?
Basicly my question is, where do I have to put my code that I still have the window shown (to edit the DC) but closing after my code is done.
thanks for help
|
|
|
|
|
Try posting WM_DESTROY message. By the way, this should also be the message windows sends when the X button is pressed (upper right of window title).
You can respond to this message inside of afx_msg void OnDestroy() function.
Hope this helps
Mike Ellertson
|
|
|
|
|
Hi!
I have a problem with Autoscrolling in an CEdit. The Code i written works fine for scrolling but has an ugly graphic-error.
It scrolls the text in the direction where i have the mousecursor. If i scroll up the first visible line is shown 2 times.
When I scroll down it is the last visible line.
Here is the code:
// MyEdit.cpp: Implementierungsdatei
//
#include "stdafx.h"
#include "MyEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// MyEdit
MyEdit::MyEdit()
{
iScrollCount = 0;
iScrollSpeed = 5;
}
MyEdit::~MyEdit()
{
}
BEGIN_MESSAGE_MAP(MyEdit, CEdit)
//{{AFX_MSG_MAP(MyEdit)
ON_WM_SETCURSOR()
ON_WM_NCHITTEST()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen für Nachrichten MyEdit
BOOL MyEdit::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Code für die Behandlungsroutine für Nachrichten hier einfügen und/oder Standard aufrufen
HCURSOR g_CursorIcon;
g_CursorIcon=LoadCursor (NULL,IDC_SIZENS);
SetCursor(g_CursorIcon);
//return CEdit::OnSetCursor(pWnd, nHitTest, message);
return 1;
}
UINT MyEdit::OnNcHitTest(CPoint point)
{
// TODO: Code für die Behandlungsroutine für Nachrichten hier einfügen und/oder Standard aufrufen
CRect rect;
GetClientRect( &rect );
ScreenToClient(&point);
if(point.y > (rect.bottom - 60))
{
KillTimer(0);
SetTimer(1,25,0);
}
else if(point.y < 60)
{
KillTimer(1);
SetTimer(0,25,0);
}
else
{
KillTimer(0);
KillTimer(1);
}
return CEdit::OnNcHitTest(point);
}
void MyEdit::SetScrollSpeed(int Speed)
{
iScrollSpeed = Speed;
}
void MyEdit::OnTimer(UINT nIDEvent)
{
// TODO: Code für die Behandlungsroutine für Nachrichten hier einfügen und/oder Standard aufrufen
CPoint point;
GetCursorPos(&point);
ScreenToClient(&point);
CRect rect;
GetClientRect( &rect );
if(point.y > rect.bottom || point.y < 0 || point.y < rect.bottom && point.x < rect.left ||point.y < rect.bottom && point.x > rect.right )
{
}
else
{
if(nIDEvent == 1)
{
if(iScrollCount == iScrollSpeed)
{
LineScroll(1,0);
iScrollCount = 0;
}
else
iScrollCount++;
}
else
{
if(iScrollCount == iScrollSpeed)
{
LineScroll(-1,0);
iScrollCount = 0;
}
else
iScrollCount++;
}
}
CEdit::OnTimer(nIDEvent);
}
#############################################################
Does anyone know what to do for showing the scrolled text correctly?
Patrick
|
|
|
|
|
Hi,
I have to programs, both written in MDI, MFC,
I am able to call the executable of program2 from program1, by using CreateProcess method.
My question is, How can I call the methods of program2, within program1.
or how can I have a pointer to the View class of program2 from program1.
Thanks
Ehsan Behboudi
|
|
|
|
|
They are two processes in different address spaces. You cannot access objeects between address spaces. One solution to sharing data is file-mapping. Another solution is pipe. Another solution is WM_COPYDATA.
Kuphryn
|
|
|
|
|
1) You can use Automatization. You must create type library from View class of program2, and after calling CreateProcess in program1, attach to running Program2's instance. You can provide values, with which you would be able to change variable values in program2, from program1, execute some code in program2(methods), etc. program2 will be server of Automatization and program1 will be client n this case.
yiy
|
|
|
|
|