|
I Want to draw one line in two windows, when I move my mouse in one window, I draw one line from top to bottom。
There is another window at the bottom of this window,I also want to draw one line in this window, if I Sendmessage to do it,
It looks like draw two lines。
|
|
|
|
|
You need to give some more details about this, the normal way is to capture the details of the line(s) in your program somewhere (e.g. on mouse moves) and then render the actual details in your paint procedure(s), and each window should have its own paint handler.
|
|
|
|
|
I am developing a viz plugin for WMP and I'm having an issue with the property page "saving" the changes I make. I generated the plugin files from the wizard found in the latest Windows SDK - this is mainly straight from the wizard and doesn't work out of the box. Great job, Microsoft!
The plugin dumps out color values over a network socket. That part works fine and no issues. I have implemented a 'property page' dialog box that, in theory, lets you pick the color value that will be sent.
In my property page dialog box code, I am setting a pointer to the plugin class itself so I can access it's variables. After exiting the dialog box though, the vis plugin class' constructor gets called again, thereby re-initializing the variable i just modified. because of this, i am unable to change any variables and the property page dialog box is useless.
My plugin class is named <b>CWmpplugin1</b>
Here are the methods of the plugin I think are relevant to this issue:
CWmpplugin1::CWmpplugin1() :
m_hwndParent(NULL),
m_clrForeground(0x0000FF),
m_nPreset(0)
{
wcsncpy_s(m_wszPluginText, sizeof(m_wszPluginText) / sizeof(m_wszPluginText[0]), L"DEFAULT", sizeof(m_wszPluginText) / sizeof(m_wszPluginText[0]));
}
wcsncpy initializes the public variable m_wsxPluginText to "DEFAULT". Problem is, this gets called after leaving the property page dialog box, so that string is always set to "DEFAULT"
STDMETHODIMP CWmpplugin1::DisplayPropertyPage(HWND hwndOwner)
{
CPropertyDialog dialog(this);
dialog.DoModal(hwndOwner);
return S_OK;
}
STDMETHODIMP CWmpplugin1::GetCapabilities(DWORD * pdwCapabilities)
{
if (NULL == pdwCapabilities)
{
return E_POINTER;
}
*pdwCapabilities = EFFECT_HASPROPERTYPAGE;
return S_OK;
}
My dialog implementation (ATL):
#include "atlwin.h"
class CPropertyDialog : public CDialogImpl<CPropertyDialog>
{
public:
enum { IDD = IDD_PROPERTYDIALOG };
BEGIN_MSG_MAP(CPropertyDialog)
MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog )
COMMAND_ID_HANDLER( IDOK, OnOK )
COMMAND_ID_HANDLER( IDCANCEL, OnCancel )
END_MSG_MAP()
CPropertyDialog(CWmpplugin1 *pPlugin)
{
m_pPlugin = pPlugin;
}
private:
CWmpplugin1 *m_pPlugin;
On constructor being called, I am getting the pointer to the plugin object.
LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hwndCtl, BOOL& fHandled)
{
wcsncpy_s(m_pPlugin->m_wszPluginText, sizeof(m_pPlugin->m_wszPluginText) / sizeof(m_pPlugin->m_wszPluginText[0]), L"CHANGED!", sizeof(m_pPlugin->m_wszPluginText) / sizeof(m_pPlugin->m_wszPluginText[0]));
EndDialog( IDOK );
return 0;
}
After you click the OK button on the dialog box, wcsncpy copies "CHANGED!" to mpPlugin->m_wszPluginText.
I attached a debugger and verified that the string is actually changing the value, but again, once the dialog exits, the plugin object constructor is called again and the string changes back to "DEFAULT" like before.
Anybody know what I'm doing wrong? Is the constructor getting called again normal operation? I thought once the DLL was loaded by WMP, it would create an instance of the plugin object that lasts for the entire time WMP is in memory.
Much thanks for any help!
|
|
|
|
|
I would like to handle LVN_DELETEITEM in my subclass:
class DailyProgramListView :
public ATL::CWindowImpl<DailyProgramListView, WTL::CListViewCtrl, ATL::CWinTraitsOR<LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL>>,
public WTL::CCustomListViewDraw<DailyProgramListView> {
BEGIN_MSG_MAP_EX(DailyProgramListView)
MSG_WM_CREATE(OnCreate)
MSG_WM_SIZE(OnSize)
REFLECTED_NOTIFY_CODE_HANDLER_EX(LVN_DELETEITEM, onDeleteItem)
NOTIFY_CODE_HANDLER_EX(LVN_DELETEITEM, onDeleteItem)
CHAIN_MSG_MAP_ALT(WTL::CCustomListViewDraw<DailyProgramListView>, 1)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
};
For some reason, the LVN_DELETEITEM is still only posted to the parent of the listview.
The parent has REFLECT_NOTIFICATIONS_EX() in its MSGMAP.
Happy coding,
Philipp Kursawe
|
|
|
|
|
Dears,
Please see the below code.
int main(int argc, char* argv[])
{
int* p = new int;
*p = 0;
int& k = *p;
k = 15;
return 0;
}
Doubt is regarding the reference usage as specified in int& k = *p; .
Actually this code works fine. But I want to know whether this code is OK or not. I mean whether any issues will happen in future.
Thanks in advance,
Krishnakumar
|
|
|
|
|
Krishnakumartg wrote: I mean whether any issues will happen in future.
In respect of what? Since this code effectively does nothing it's impossible to guess what issue you are facing.
|
|
|
|
|
Actually i wrote the sample code here.
I want to use similar code in one of my projects.
|
|
|
|
|
Krishnakumartg wrote: I want to use similar code in one of my projects.
I see no reason not to. However if you have a further question please post it.
|
|
|
|
|
You mean that its an obvious thing.. right??
i am just confirming it
|
|
|
|
|
Krishnakumartg wrote: You mean that its an obvious thing.. right??
What is? I am still not sure what your concerns are.
|
|
|
|
|
Hi all!
I am developing an add-in for Word 2003. It can insert a bitmap into .doc file after some operations by user.
Question:
When I insert only one BMP into .doc file, the picture can display correctly. If more than one BMP inserted, the picture can't displayed after save and re-open. I research this problem and find that the method named "InPlaceActivate" is called while only one BMP inserted. If more BMPs are inserted, this method can't be called. I am not sure which interface owned this method. So I research the interfaces be queried in both scenery. The different between them is that the interface as "IID_IOleXXX" will be queried if I add only one BMP. If I add more BMP into .doc file, those interfaces as "IID_IOleXXX" aren't be queried. Then the BMP can't be displayed. I think this is the reason. I try to resolve it by many ways. But all failed. Is there anybody could be kind to help me? Thank you!
Best regards!
There is some white cloud floating on the blue sky. That's the landscape I like.
modified on Tuesday, March 29, 2011 4:06 AM
|
|
|
|
|
Hi
I just wanted to replace a '%' character in CComBSTR with "%%". But the code does not support CString. The solution should be UNICODE support.
Any methods to perform this operation ?
Thanks In Advance.
Babu
Today is a gift, that's why it is called the present.
|
|
|
|
|
CComBstr class doesn't have a method to replace a sub-string with another or to insert another string in specified position. All you can do is, get BSTR which is wrapped in CComBSTR class ( either by m_str member or by operator BSTR). You need to copy this to another CComBSTR. You may use its Append() method or overloaded += operators for ease.
CComBSTR str("here%are%percentages%");
CComBSTR newstr;
WCHAR split[] = L"%";
WCHAR* pos = wcstok(str.m_str, split);
while(0 != pos) {
newstr.Append(pos);
newstr.Append(L"%%");
pos = wcstok(NULL, split);
}
NOTE:
I would like to remind that BSTR data type has preceding header components, and the final string is terminated with double null characters. This is how system allocates memory for BSTR. There can be embedded single null characters in BSTR string data. In that case, wcslen() and wcstok() functions won't work as expected. Use CComBSTR::Length() or SysStringLen() to get length of string. You may need to examine each character in string till you find two continuous '\0' characters. During this, whenever you find a '%' add an additional '%' more tho the new string.
Unicode support is completely ensured.
modified on Thursday, March 24, 2011 9:09 AM
|
|
|
|
|
or ...
CComBSTR str("here%are%percentages%");
CString workingString(str);
workingString.Replace(_T("%"),_T("%%"));
str=workingString;
|
|
|
|
|
Its ok. But I guess you didn't notice "But the code does not support CString" in the actual question
|
|
|
|
|
sorry - rookie error - I'll pay more attention
you nailed it then
|
|
|
|
|
Hi
I have an MFC Dialog which contains an ActiveX control ( a small grid control developped en C# with DevExpress )
The problem appears when switch to an other application or screen until editing a row in this grid ( the cursor is inside the zone edit ).
i.e : when cursor in the edited row and switching screen -----> problem of crash ( i can't get the dialog again ; i click on the try icon but no result).
I tried to impliment the Onkillfocus()
void CApp_ToolDlg::OnKillFocus(CWnd* pNewWnd)
{
CWnd *pWnd = GetDlgItem(IDC_AXSEE_PLMPC1); // GET THE CWND OF ACTIVEX CONTROL
if( pWnd != NULL)
pWnd->SetFocus(); // TRY TO SET FOCUS ON IT
CDialog::OnKillFocus(pNewWnd);
}
|
|
|
|
|
I've used VS2010 to create C++ MFC app and MFC ActiveX component. The ActiveX accumulates data and I need to design a method that allows the MFC app to access it.
The data is stored in std::vector using struct.
I'm told there is no direct way to do this so should I store the data differently and/or how can I access it using an ActiceX method?
|
|
|
|
|
If the ActiveX control is running in the same process as the app, then there's nothing stopping you from making an interface method that returns a vector<your_struct>* . If they're in different processes, then you can't return a pointer directly to the vector. If you are using the built-in marshaler, you'll need to convert the data to OLE Automation-compatible types. That means making a SAFEARRAY that contains... well, I'm not sure. I've never had to make the OLE equivalent of a struct, so I don't know how you do that off the top of my head. Hopefully this is enough info to get started.
--Mike--
Dunder-Mifflin, this is Pam.
|
|
|
|
|
Uhu, I have not been working with C++ in a few years, only C#, ouch I have forgotten a lot...
Right now I'm working on a COM Object and I need to sign it so it will work with no warnings at my clients.
I do have a code signing cert, but I have totally forgotten how to do it.
Is there a new and easy way using VS? I'm running VS 2010.
- Anders
|
|
|
|
|
The two SDKs I have on this machine both have a signing app called signtool.exe . I also remember seeing some other signing app in an older SDK that had a wizard to lead you thru the process.
--Mike--
Dunder-Mifflin, this is Pam.
|
|
|
|
|
Of course, thanks
- Anders
|
|
|
|
|
I'm making an COM object (ATL Simple Object) and it works fine from a C# Project, and from ASP Server Side.
But when I try to create it from JSCript in a browser, with new ActiveXObject(), I get an error saying "Microsoft JScript runtime error: Automation server can't create object"
Any idea what to do?
- Anders
|
|
|
|
|
Hi all!
Now I am developing an add-in application. I had instantiated a sub-class of COM to expose the interface to Word. Then I add some commandbar buttons on the command bar. When user click a specified button, a data will be inserted into word document. The data inserted is created by an object of another class of mine, which is derived some interfaces of Word. This class can handle the event come from Word application.
When the data was inserted, user can right-click on it. Then a pop-up menu will be displayed. When an item was chosen, I need to disable the button on command bar.
Problem: I don't know how to control the button within data class. I had tried to transport the pointer of button into data class. But no appropriate way to implement it. I want to write a method and expose it as a member of interface. But I can't find a appropriate type to transport Office::CommandBarButton. I try to use IDispatch* to do it. But the code to convert and save the pointer can't through compilation. I don't know what I can do now. Is there some one can help me? Thank you!
Sincerely.
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
Hello!
I have a CTabViewImpl set as the client in a CFrameWindowImpl. I wonder how its possible to get WM_COMMAND messages from the active tab page's dialog.
When I have the same dialog template used in a modal dialog, the IDOK and IDCANCEL buttons placed in the template generate the appropriate WM_COMMAND messages.
However, when I use the dialog template as a page in the CTabViewImpl the WM_COMMAND messages are no longer generated. Usually a press on ESC oder RETURN generate the WM_COMMAND messages. Any way to have this mechanism work in embedded, non-modal dialogs too?
Happy coding,
Philipp Kursawe
|
|
|
|