|
I added a band with a checkbox with this:
m_reabr.AddBar(&m_check, "On the bar", NULL, RBBS_BREAK|RBBS_GRIPPERALWAYS)
APparently RBBS_GRIPPERALWAYS means that "sizing wrinkles" are present. WHen I ran my code I wasnt able to resize the rebar.
ALso I couldnt move it around. For this do I need to do some docking code?
Thanks
Appreciate your help,
ns
|
|
|
|
|
I tried duplicating the docking code that m_wndToolBAr has, but it asserted on the very first line:
rebar.EnableDocking(CBRS_ALIGNANY);
So what do I need to do to make my rebar move around like the standard toolbar does?
Appreciate your help,
ns
|
|
|
|
|
Hello,
I've used this code in order to get access to the HTMLDocument:
CComQIPtr<IHTMLDocument2> spHTMLDocument = this->m_HTMLCtrl.GetHtmlDocument();
if(spHTMLDocument)
{
CComQIPtr<IHTMLElement>> spHTML;
spHTMLDocument->get_body(&spHTML);
if (spHTML)
{
bstr = csCodiHTML.AllocSysString();
spHTML->put_innerHTML(bstr);
spHTML.Release();
}
else
{
bstr = csCodiHTML.AllocSysString();
spHTMLDocument->createElement(bstr,&spHTML); <code>
}
}
But the first time in which it is accessed the document doesn't exist, and I was wondering if it was possible to create it programatically.
In order to create it I've thought in doing what is written in the else clause, but it has no effect over the HTML document...
Could you give me an advice?
Thank you in advance...
|
|
|
|
|
Joan Murt wrote:
spHTMLDocument->get_body(&spHTML);
This line of code tries to retrieve the <BODY> element. Depending on what is loaded into Internet Explorer, this indeed may be NULL. In this case, a document is created after the first document.write call (translate this to C++ code).
|
|
|
|
|
OK,
in order to do that I need to use a SAFEARRAY, do you know how to work with the SAFEARRAY?
Searching to the MSDN I've not found any example...
Thank you in advance...
|
|
|
|
|
Here is a sample code :
LPVOID ptr = "my text";
LPSAFEARRAY psa;
UINT cElems = lstrlen( (char*)ptr );
LPSTR pOutput;
psa = ::SafeArrayCreateVector(VT_UI1, 0, cElems);
if (!psa)
return;
::SafeArrayAccessData(psa, (LPVOID*)&pOutput);
memcpy(pOutput, ptr, cElems);
::SafeArrayUnaccessData(psa);
pHtmlDoc->write( psa );
::SafeArrayDestroy( psa );
|
|
|
|
|
I don't understand why, but it has not worked as I expected...
it seems that the document is not created as it should be...(I'll try again...)
but thank you for your cute sample...
One question:
at the beggining you assign "my text" to a LPVOID ptr, how do I assign a CString to that ptr?
Thank you in advance!
|
|
|
|
|
HI,
How to access USB port from VC++?
I have used DirectInput IDirectInput8::EnumDevices() but it's not working
How to use DirectInput to access USB port, and enumerate
all devices attached to computer?
thnaks
|
|
|
|
|
I've seen few good source code here at CP implementing POP3 and SMTP protocol, but not a single that implements IMAP protocol. If you know any such code that implements IMAP, then please inform me.
|
|
|
|
|
Hello
I want to create a baseclass for socket servers that use io completion ports.
But I cant manage to pass a class function to BindIoCompletionCallback.
BOOL BindIoCompletionCallback(
HANDLE FileHandle,
LPOVERLAPPED_COMPLETION_ROUTINE Function,
ULONG Flags
);
I call it with:
BindIoCompletionCallback((HANDLE)m_sdListen, DoneIO, 0);
My class looks like:
class IocpServer
{
public:
IocpServer(void);
~IocpServer(void);
void CreateListenSocket(int ListenPort);
void Start(void);
HANDLE GetDieEvent();
void CALLBACK DoneIO(DWORD dwErrorCode,
DWORD dwNumberOfBytesTransferred,
LPOVERLAPPED lpOverlapped);
private:
SOCKET m_sdListen;
DWORD m_dwThreadCount;
HANDLE m_hIOCP;
UINT m_iListenPort;
HANDLE m_hDieEvent;
};
I get this error:
d:\projects\cpp\Datatal\HvdServer\IocpServer.cpp(24) : error C2664: 'BindIoCompletionCallback' : cannot convert parameter 2 from 'void (DWORD,DWORD,LPOVERLAPPED)' to 'LPOVERLAPPED_COMPLETION_ROUTINE'
None of the functions with this name in scope match the target type
|
|
|
|
|
I guess, that if the DoneIO is the member of your class, you can't do it in that way. The DoneIO can be a member only if it is a static member, then you can use it for callbacks. Normal class members have calling convention _thiscall, which you cannot achieve in callbacks. So for you it will help to make that function static (static members do not have the first hidden parameter - this).
|
|
|
|
|
I'm using MSVC++6, and I have a normal Doc/view application.
I have an item in the File menu, which iniates a dialog. How can I initiate the dialog automatically when the application is started, _after_ the application window is fully visible?
I have placed a call to the function in more places than I want to think about, and I always get the dialog _before_ the application window is drawn.
I'm just so tired of that, so tired...
|
|
|
|
|
Try to add the dialog call in the InitInstance() function of your application before you return the function.
BOOL CTestApp::InitInstance()
{
...
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
...
CMyDialog dlg;
dlg.DoModal();
return TRUE;
}
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
The function is in CView derived class. How could I get a pointer there so I won't have to rewrite the code in InitInstance?
(Explanation: The OnFileSelectserver() function is in CView derived class, and it has calls to CDocument derived class. Now it would need to be called from CWinApp based class.)
|
|
|
|
|
What kind of pointer do you have in CView derived class?
I thought you want do display a dialog after showing the application ... is that right?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Yes, I want to show a dialog *after* showing the application window. All solutions I have tried will show the dialog before painting the application window.
Err.. I am not sure what you mean with "what kind of pointer do you have in CView derived class".
The only flaw in my application (that I know of ) is that the dialog should be iniated automatically instead of having to iniate it from menu. The menu item is handled in CView derived class (CMyView), in OnFileSelectserver() function. That function has calls to CDocument derived class (CMyDocument).
So I need to be able to call CMyView::OnFileSelectserver() from inside CWinApp based class (CMyApp), in InitInstance(). How to do that?
Putting the CMyView::OnFileSelectserver() in CMyView::OnInitialUpdate() causes the dialog to be shown first, then a pause as the program gathers data and only after that the application is shown. Doing that skips the progress bar and gives the impression that nothing is happening. That's the problem. First application window, THEN dialog.
|
|
|
|
|
Add the following code lines in your InitInstance function of your application:
...
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
CYourView* pView = (CYourView*) ((CFrameWnd*) m_pMainWnd)->GetActiveView();
pView->SendMessage(WM_COMMAND, ID_for_your_OnFileSelectserver_menu_item, 0);
return TRUE;
Insert the right ID for the ID_for_your_OnFileSelectserver_menu_item in the SendMessage function.
I hope this helps you!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
This looks like exactly what I need! Thanks!
(I can't test it in action until Monday, but I am sure it will work.)
|
|
|
|
|
...aaand perfectly it did the job!
|
|
|
|
|
Fine!
Nice greets from Tyrol / Austria, Daniel.
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
If you want to fire you dialog right after the application starts, that is before a document has been opened, you will have to do it as was posted. But if you want your dialog to open after a document had been loaded and its view had been created, you could use your views OnInitialUpdate() message handler.
A pointer to the active (SDI-)view can be obtained using CFrameWnd::GetActiveView() .
(For MDI, there is a possibility shown in that MSDN entry).
--
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
Hello,
I'm using this code but I'm novice with all the vars involved (it's the first time I use them) and I don't know how to free them...
This code is very used in my app and I can see that the memory resources are getting smaller and smaller every cycle...
//---------------------------------------------
// VARIABLES INVOLVED...
//---------------------------------------------
IHTMLDocument2* pHTMLDocument2;
LPDISPATCH lpDispatch;
IHTMLElement* pBody;
BSTR bstr;
HRESULT hr;
//---------------------------------------------
// CODE USED
//---------------------------------------------
lpDispatch = this->m_HTMLCtrl.GetHtmlDocument();
if (lpDispatch)
{
hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDocument2);
lpDispatch->Release();
hr = pHTMLDocument2->get_body(&pBody);
bstr = csCodiHTML.AllocSysString();
if (pBody)
{
pBody->put_innerHTML(bstr);
pBody->Release();
}
SysFreeString(bstr);
}
|
|
|
|
|
Well you never seem to release the pHTMLDocument2 interface. Thats probably your problem. Then you would probably be better off using smart pointers. If you are using ATL (which you should be ) you can use the CComPtr<> template class. There are even some predefined smart pointers that have already beed defined, IHTMLDocument2Ptr and IDispatchPtr to name few. Then you should be using CComBSTR to manage all BSTR's you are allocating. You can use it directly with CString:
<br />
CString strHTML( _T("some html code") );<br />
CComBSTR bstrHTML = strHTML;<br />
But of course you still need to learn the refcounting rules of COM if you want to know what you are doing
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
OK, I've placed the release that you've mentioned...
but is still behaving equal...
I'm thinking on try the other mentioned method:
dabs wrote:
CComPtr<> template class.
Could you give me a little example on how to do it?
Only the guidelines on how to use those pointers:
CComPtr<IHTMLDocument2Ptr> pHTMLDocPtr;
CComPtr<IDispatchPtr> pIDispatchPtr;
pIDispatchPtr = this->m_HTMLCtrl.GetHtmlDocument(); <code>this is not working</code>
I've tried something and it has not worked, and MSDN texts are so... "esoteric" for me...
Thank you in advance...
|
|
|
|
|
CComPtr is a template, so you have to specify the template parameter, this is a first. But it might be a mistake when inserting the text here. It consider it as unknown html tag, but for any case:
<br />
CComPtr<IHTMLDocument> spHTMLDocPtr;<br />
CComPtr<IDispatch> spIDispatchPtr;<br />
the second part I am not sure how it works in your case, but the most usual use of the interface pointers is:
m_htmlCtrl.GetHtmlDocument( &spIDispatchPtr );
this is because if the method is designed as you wrote
spPtr = GetMethod();
the method probably adds one reference (AddRef) to the returned pointer, but if you attach it to the smart pointer (ccomptr) he is not smart enough here and add another more addref. So you have 2 addrefs, and only one will be released in the ccomptr destructor. Hence here you should use something like spIDispatchPtr.Attach( this->...GetHtmlDocumet() );
Hope that I am not wrong
|
|
|
|