|
I don't think you can do such a thing since the library is linked to active processes and will be held in memory until released by every process. See the FreeLibrary() [^] function for details. It would help if you explained exactly what you are trying to achieve.
|
|
|
|
|
Hello everyone,i need your help,how do i add a code that will pop up a help menu when i click a button,on an MFC program that uses handles.? i have put a main code below
Quote: #include "main.h"
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
double *X,*Y;int N=0;
void InitDialog(HWND hDlg)
{
HWND hCombo=GetDlgItem(hDlg,IDC_MENU);
SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)L"Edit");
SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)L"Draw");
SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)L"About");
SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)L"Exit");
}
void PaintDialog(HWND hDlg)
{
HWND wnd=GetDlgItem(hDlg,IDC_PAINTBOX);
PAINTSTRUCT ps;HDC dc=BeginPaint(wnd,&ps);
RECT size;GetClientRect(wnd,&size);
Rectangle(dc,size.left,size.top,size.right,size.bottom);
DrawGraph(dc,size,X,Y,N);
EndPaint(wnd,&ps);
}
void DrawButton(HWND hDlg)
{
WCHAR BUF[MAX_PATH];
// анализ начала интервала
GetDlgItemText(hDlg,IDC_EDIT_START,BUF,MAX_PATH);
if(analysis(BUF)==NULL)
{
MessageBox(hDlg,GetErrorMsg(),L"Error",MB_ICONHAND|MB_OK);
return;
}
double start=calc(0);
// анализ конца интервала
GetDlgItemText(hDlg,IDC_EDIT_END,BUF,MAX_PATH);
if(analysis(BUF)==NULL)
{
MessageBox(hDlg,GetErrorMsg(),L"Error",MB_ICONHAND|MB_OK);
return;
}
double end=calc(0);
// анализ шага интервала
GetDlgItemText(hDlg,IDC_EDIT_STEP,BUF,MAX_PATH);
if(analysis(BUF)==NULL)
{
MessageBox(hDlg,GetErrorMsg(),L"Error",MB_ICONHAND|MB_OK);
return;
}
double step=calc(0);
GetDlgItemText(hDlg,IDC_EDIT_EXPR,BUF,MAX_PATH);
// анализ выражения
if(analysis(BUF)==NULL)
{
MessageBox(hDlg,GetErrorMsg(),L"Error",MB_ICONHAND|MB_OK);
return;
}
// расчёт интервала
if(!interval(start,end,step,&X,&Y,&N))
{
MessageBox(hDlg,GetErrorMsg(),L"Error",MB_ICONHAND|MB_OK);
return;
}
// отрисовка промежуточных значений
HWND hList=GetDlgItem(hDlg,IDC_LIST);
SendMessage(hList, LB_RESETCONTENT, 0, 0);
for(int i=0;i<n;i++)
{
="" swprintf(buf,max_path,l"(%4.4lf="" ,="" %4.4lf)",x[i],y[i]);
="" sendmessage(hlist,lb_addstring,0,(lparam)buf);
="" }
="" принудительная="" отрисовка
="" invalidaterect(hdlg,null,false);
}
void="" savebutton(hwnd="" hdlg)
{
="" wchar="" filename[max_path];=""
="" if(showsavedialog(
="" hdlg,
="" filename,
="" l"fndraw="" save="" to="" file",
="" null,="" l"c:\\windows\\desktop",="" l"bmp="" files="" (*.bmp)\0*.bmp\0"
="" ))
="" storeclientwindowbitmap(getdlgitem(hdlg,idc_paintbox),filename);=""
}
void="" helpbutton(hwnd="" hdlg)
{
}
="" оконая="" процедура
lresult="" callback="" dialogproc(hwnd="" hdlg,="" uint="" message,="" wparam="" wparam,="" lparam="" lparam)
{="" обработка="" сообщений
="" switch(message)
="" {="" инициализация="" окна
="" case="" wm_initdialog:
="" initdialog(hdlg);
="" return="" true;
="" отрисовка="" wm_paint:
="" paintdialog(hdlg);
="" break;
="" нажатых="" кнопок
="" wm_command:="" выбор="" switch(wparam)
="" потом="" убрать...
="" (hwnd)(idc_menu):
="" if="" (hiword(wparam)="=CBN_EDITCHANGE)
" int="" item="ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_MENU));
" item;
="" break;="" сценарий="" закрытия="" loword(idc_button_exit):
="" enddialog(hdlg,0);
="" сохранений="" графика
="" loword(idc_button_save):="" savebutton(hdlg);
="" построения="" нового="" loword(idc_button_draw):
="" drawbutton(hdlg);
="" }="" wm_close:="" *enddialog(hdlg,0);="" *="" false;
}
int="" winapi="" winmain(hinstance="" hinstance,="" hinstance="" hprev,="" lpstr="" lpcmdline,="" ncmdshow)
{
="" initcommoncontrolsex="" icc;
="" icc.dwsize="sizeof(INITCOMMONCONTROLSEX);
" icc.dwicc="ICC_WIN95_CLASSES|ICC_STANDARD_CLASSES;
" initcommoncontrolsex(&icc);="" dialogbox(hinstance,="" makeintresource(idd_main),="" (dlgproc)="" dialogproc);=""
}<="" blockquote="">
|
|
|
|
|
I am facing a strange issue.It is working well with outlook 2K3 but not anymore on outlook 2K7 and 2K10.
Problem - If I drag a file from my application and drop onto the message body in a new message in outlook 2007 nothing happens. Instead the expected behavior is - file should attach to the message. It work well in outlook 2003 and I haven't made any change in my code.
If I drag file from my application and drop on to windows desktop, it works without any problem. Now if I drag the same file from Windows desktop and drop onto the new message in outlook 2007, file gets attached. This leaves me guessing that there is something need to change in my code but I unable to figure out.
Investigation -
We have implemented the CFSTR_FILEDESCRIPTOR, CFSTR_FILECONTENTS and CF_TXT in the CDataObject::Getdata() method. I have noticed is that in case of outlook 2007, when I drop file(from my application) to message body in new message, only CFSTR_FILEDESCRIPTOR clipboard format is called. While in case of outlook 2003, if I drop file(from my application) to message body in new message CDataObject::GetData() is called two times, CFSTR_FILEDESCRIPTOR followed by CFSTR_FILECONTENTS clipboard formats.
In the second file contents are extracted since GetData is not called second time hence file is not attached to email. Following is the sample code.
Does anyone know what could be the reason ? Or what else i can try to narrow down the issue.
STDMETHODIMP CDataObject::GetData (
LPFORMATETC pFE,
LPSTGMEDIUM pSTM)
{
HGLOBAL hMem;
LPFILEGROUPDESCRIPTOR pfgd;
UINT uFormat, uBytes;
void* p;
m_uFmtUsed = 0;
uFormat = pFE->cfFormat;
if (uFormat == m_fe[0].cfFormat)
{
if (!(pFE->dwAspect & DVASPECT_CONTENT))
return DV_E_DVASPECT;
if (!(pFE->tymed & TYMED_HGLOBAL))
return DV_E_FORMATETC;
hMem=GlobalAlloc (GMEM_SHARE | GMEM_MOVEABLE,
sizeof(FILEGROUPDESCRIPTOR));
if (hMem == NULL)
return STG_E_MEDIUMFULL;
pfgd = (LPFILEGROUPDESCRIPTOR)GlobalLock (hMem);
pfgd->cItems = 1;
pfgd->fgd[0].dwFlags = FD_ATTRIBUTES;
pfgd->fgd[0].dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
lstrcpy (pfgd->fgd[0].cFileName, m_pszName);
GlobalUnlock (hMem);
pSTM->hGlobal = hMem;
pSTM->tymed = TYMED_HGLOBAL;
pSTM->pUnkForRelease = NULL;
m_uFmtUsed = uFormat;
return S_OK;
}
else if (uFormat == m_fe[1].cfFormat)
{
if (!(pFE->dwAspect & DVASPECT_CONTENT))
return DV_E_DVASPECT;
if (!(pFE->tymed & TYMED_HGLOBAL))
return DV_E_FORMATETC;
if (!m_pData)
{
m_pData = PKDropKeysGetData (
(PPGPKEYSSTRUCT)m_pKeysStruct, FALSE, FALSE, &uBytes);
}
hMem = GlobalAlloc (GMEM_SHARE|GMEM_MOVEABLE, uBytes);
if (hMem == NULL)
return STG_E_MEDIUMFULL;
p = GlobalLock (hMem);
memcpy (p, m_pData, uBytes);
GlobalUnlock (hMem);
pSTM->hGlobal = hMem;
pSTM->tymed = TYMED_HGLOBAL;
pSTM->pUnkForRelease = NULL;
m_uFmtUsed = uFormat;
return S_OK;
}
....
.....
....
return DV_E_FORMATETC;
}
Rahul Sisondia
|
|
|
|
|
I think I have found a bug in the CString assignement operator of the ATL/MFC 8.
CStringT& operator=( __in_z_opt PCYSTR pszSrc )
The method calculates the length of the required buffer and allocates the buffer. The calculation does not include the terminating null character. Thereafter it calls MultiByteToWideChar, passing the length as the cchWideChar parameter.
The function MultiByteToWideChar returns 0 as failure indication, but this is ignored by the MFC. As a side effect, MultiByteToWideChar fills the output buffer on some platforms like Win32 and Windows CE 5.0 (SH4).
But the Windows CE 5.0 (x86) implementation of MultiByteToWideChar does not fill the buffer. Although the allocated buffer is too small, the bug is not visible on most platforms but on Windows CE 5.0 (x86). Here you get an empty CString after the assignment.
Example:
CStringW s("ABC");
PCWSTR p = (PCWSTR)s;
assert(0 != p[0]); The assert in the code above fails.
|
|
|
|
|
Very interesting, but I think you should be telling Microsoft.
|
|
|
|
|
I'm working on attributed ATL DLL which establish communication with some hardware.
I need to raise event in all clients when hardware signals.
Also, I would need to have access to same variable from all clients. This variable actually holds registers from hardware.
Can someone point me in right direction how to accomplish this?
I have a hardware communication code ready just need to figure out how to rise event in all clients and have them read same register variable.
Thank you.
Ljube
|
|
|
|
|
Create your class as a singleton, you need to make it an event source, and the consumers an event_receiver - there's an example here on CP
As far as the common variable is concerned, you can either pass it byvlaue in the event, or expose it as a property/via a method
You'll have to put some locking in the singleton too, to stop your host changing the value while the clients are looking at it
|
|
|
|
|
Thanks. First tests looks promising!
Ljube
|
|
|
|
|
Hello,
I have a multi threaded MFC exe built with all its basic classes including CSocket, with TCP connection through mainframe etc. , I want to split it to two different components. ATL service and MFC GUI. Can I do it and can I use the MFC classes in the ATL service.
Thanks in advance,
Eyal
|
|
|
|
|
You can certainly split it up, yes
Some of the MFC classes are now shared with ATL, I'm not too sure about CSocket - I would guess not very easily, looking at the afxsock header
|
|
|
|
|
Hey there guys,
I have an almost opinion question. I am writing an instant messenger software, and I am trying to decide on the internal API parsing method. I cannot decide if I want to have a one-size-fits-all method that parses the entire command then returns the specific section I need, or less simple-to-use library of functions that read individual functions.
Basically, the command structure is like this: (Let's say you are registering a new connection)
REG(##,{your username},{the password salted hash})
My first method would return the username when called as api_GETVALUE(2,"REG(33,username,passwordsalthash)"). If I changed the first argument to 1, it would return 33 (the length).
If I did individual functions, I could get the length by calling api_GETLENGTH with the string as a parameter, api_GETUSERNAME for the username, etc.
How would you guys do it personally?
--
Collin
|
|
|
|
|
Your first option would have a problem in that you would have a single function that returns either a stirng (or maybe pointer to string) or an integer. But this is not legal in C++, as the compiler cannot distinguish (from return type alone) which one you mean. A better option would be to create a class (or structure) that holds the user information and has methods (getters) that return the relevant properties.
|
|
|
|
|
first sorry for my poor english..
i have an "ATL simple object" interface like "IErrSupport" , and i want to use it as a parameter like:
(ISomething) DoSomething(...,IErrSupport *pErr);
...
(IOtherthing) DoOtherthing(...,IErrSupport *pErr);
can anybody give me an example? thanks a lot.
|
|
|
|
|
(IOtherthing) DoOtherthing(...,IErrSupport *pErr);
Assuming that pErr points to an object that implements IErrSupport then you already have it.
|
|
|
|
|
i assumed like that ,but i don't know what to do .
my step:
1. crete a new atl project, maybe it named TestA.
2. Add a class "A";
3. IA Add methods like TestErr(IErrSupport *pErr);
4. compiling...
.\TestA.idl(19) : error MIDL2025 : syntax error : expecting a type specification near "IErrSupport"
.\TestA.idl(19) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
5. add import "../ErrSupport/ErrSupport.idl"; to TestA.idl ,compiling...
d:\errsupport\testa\testa_i.h(69) : fatal error C1083: Cannot open include file: 'ErrSupport.h': No such file or directory
|
|
|
|
|
astupidboy wrote: fatal error C1083: Cannot open include file: 'ErrSupport.h': No such file or directory
That should give you a clue.
|
|
|
|
|
but there's no such file ...
could you leave your email,and i send the project to you ?
|
|
|
|
|
astupidboy wrote: but there's no such file
Then you need to create it.
astupidboy wrote: could you leave your email,and i send the project to you ?
Sorry, no, I'm not an ATL expert, and don't have the tools to build it.
|
|
|
|
|
|
|
any example? i'm too stupid
|
|
|
|
|
Hello, I have a recordset which contains a lot of data , I need to save it into map or any kind of dictionnary (which have a key and other data)
I have for example :
pRecordset->MoveFirst();
while (!pRecordset->EndOfFile)
{
vIdTrans =pRecordset->Fields->Item["id_translation"]->Value;
vCaption =pRecordset->Fields->Item["id_caption"]->Value;
vLang =pRecordset->Fields->Item["id_language"]->Value;
vTranslation =pRecordset->Fields->Item["translation_text"]->Value;
strIdTrans = CUtils::GetVariantAsCString(vIdTrans);
strCaption = CUtils::GetVariantAsCString(vCaption);
strLang = CUtils::GetVariantAsCString(vLang);
strTranslation = CUtils::GetVariantAsCString(vTranslation);
- id_translation : key of table
- id_caption and id_language are REFERENCES from other tables.
- translation_text : data
So , what I need after is getting data by (id_caption and id_language) and it will be more better if (id_caption, id_language and id_translation)
how do that ?
}
|
|
|
|
|
|
I have the chain of inheritance :
coclass _A
{
[default] interface _IA;
};
coclass _A_1
{
[default] interface _IA_1;
};
coclass A
{
[default] interface IA;
[default, source] dispinterface _IA_ControllerEvents;
};
interface _IA : IDispatch{
interface _IA_1 : _IA{
interface IA : _IA_1{
all class inherits from IDispatchImpl
In the COM map of the class CA that expose the interface IA, I didn't know the correct code and how I manage the macros COM_INTERFACE_ENTRY and COM_INTERFACE_ENTRY2
So I do :
BEGIN_COM_MAP(CA)
COM_INTERFACE_ENTRY(IA)
COM_INTERFACE_ENTRY2(IDispatch, _IA)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(_IA)
COM_INTERFACE_ENTRY(_IA_1)
END_COM_MAP()
is this correct ? or should I add an other macro COM_INTERFACE_ENTRY2 like this :
COM_INTERFACE_ENTRY2(_IA, _IA_1)
?
Thank you.
|
|
|
|
|
Hi,
I have understood that in Windows 8 CP x64 the IE 10 is a 64 bit browser, but it is triggering 32 bit containers while Enhanced protected mode if OFF.
In this scenario, I am trying to lunch a .exe from my ActiveX using create process. Here createprocess() is failing with GetlastError() returning ZERO.
The same code works fine and successfully launching the .exe in Protected mode off.
Can any one put some light what additional stuff need to be done to achieve above mentioned scenario.
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|