|
Thanks for your help!
but I'm a beginner,and I don't know how to set the WH_CBT
hook.Can you explain it more clearly or post code to me?
|
|
|
|
|
Hi,
I have a CFormView based application. The dialog is created using the dialog editor. When I compile and run the program the initial size of the window is always too small to show all controls, resulting in ugly scrollbars.
I am looking for a smart way that ensures that the initial size of the application window is just big enough to show all controls.
How do I do this?
Woody
|
|
|
|
|
Look at WM_GETMINMAXINFO. You can specify the min and max size of your frame, so your formview fits.
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
Thanks. One more question. How do I determine the required size. For example, I draw four listboxes next to each other. How do I determine the total size of these listboxes and thus the total dialog size.
Woody
|
|
|
|
|
|
Hi!
I am trying to build an SDI with some dialog box in it. Those dialog box contain buttons. I want be able to click those button and then retreive data from my CDoc derived class and then do some process with it. After that I want to update the list box in the dialog box.
I've tried adding message handler in the dialog box class but then I can't process the data as I can't get to the data in CDoc like the CView class did by using GetDocument(). I've tried many things but it did not work. Can a button in dialog box be used to invoke a function in CDoc or CView derived class?
Does anyone knows how to retrieve and send data from dialog box to CDoc derived class or CView derived class? I desperately need some example
Newbies
|
|
|
|
|
Add a document pointer to your dialog class and set it before calling DoModal(). This will give you access to the document when the user clicks the button:
class CMyDlg : public CDialog<br />
{<br />
public:<br />
CMyDocument *pDoc;<br />
};<br />
<br />
CMyDocument::OnShowDlg()<br />
{<br />
CMyDlg dlg;<br />
dlg.pDoc = this;<br />
}
Capixx?
Drinking In The Sun
Forgot Password?
|
|
|
|
|
I had exactly the same Q. My understanding, however, is that the dialog should be placed in the view, and not the document. the 'CMyDocument::OnShowDlg()' line in one of the replies before implies that the dialog is not part of the view. Is that correct?
Isn't there a way to have the DDX from the dialog directly update member variables in the document class? Dialogs updating document class(es) seems to be such a common occurence, such that someone must have a straightforward answer to this. Thx you all,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
Hey Zayax,
I'm new too, but I think you want to use DDX. Essentially, you create a link between the dialog and it's parent, and transfer info that way. I'm still learning about, and it's caused me some headaches over the past few days, but try that direction in your searching.
Hope that helps some.
BW
{insert witty/thought-provoking saying here}
|
|
|
|
|
Special thanks to all the Gurus that had help me. Sorry I can't respond earlier to your reply because my internet provider connection has been down until now. Your advice has worked. Keep up the good work. Arigato Gozaimashita
Newbies
|
|
|
|
|
For using Smart Pointer, it'll handle all reference counting for me. However, for some cases, I couldn't use it.
Can anyone tell me the following functions if AddRef() is called automatically, or I should call it explicitly.
1. CComObject<t>::CreateInstance()
2. CComObject<t>::QueryInstance()
3. CoCreateInstance()
4. SmartPtr->CreateInstance() -- (i supposed addref-ed auto)
5. SmartPtr->QueryInterface() -- (i supposed addref-ed auto)
6. pUnknown->QueryInterface()
I see from many samples, the codes are just called CoCreateInstance() or pUnknown->QueryInterface() to return the pointer directly without calling AddRef(). It will do automatically ?
|
|
|
|
|
All of those functions call add ref before returning the pointer.
QueryInterface calls Addref internally before returning the new interface that you are querying.
CComObject::CreateInstance calls CoCreateInstance, which internally calls QueryInterface.
Are you having any particular problems, or are you just making sure?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I tried CComObject::CreateInstance is not calling CoCreateInstance, it just called new only.
|
|
|
|
|
You are right about CComObject::CreateInstance, I forgot this is the function that creates the object in ATL. However, I still beleive that it calls Query Interface so I think you should still be safe with this function.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I need to create Dll in VC++.I created a Dll using the option Win32 Dynamic Link Library from the options and added a .def file to mention the functions exproted by the Dll.Now I want to get my Dll registered.I used the command regsvr32 Dllfilename.dll.But instead of registering a message is popped up saying ::-
Dllfilename.dll was loaded,but the DllRegisterServer entry point was not found.
DllRegisterServer may not be exported,or a corrupt version of Dllfilename.dll may be in memory.Consider using Pview to detect and remove it.
I'm not able to trace the error.Can anybody help??
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
You only need to register your DLL if it contains a COM server.
If you have simply created a DLL that exports a few API functions, then you do not need to call regsvr32.
If you want to use that DLL in another program you can call LoadLibrary then GetProcAddress to create a function pointer to the functions that you have exported from you DLL.
Or if you want to statically link your DLL to another program you can link your program to the .lib file that is created in the DLL, and that will allow you to simply call the function directly in your code.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
hi all,
i want to know how can i get my current ip in a pc? any API to acheive this?
thanks,
jim
|
|
|
|
|
#include <winsock2.h>
DWORD InitWinSock()
{
WSADATA data;
if (WSAStartup(MAKEWORD(2, 2), &data) != 0)
return WSAGetLastError();
return 0;
}
DWORD GetIpAddress(LPCTSTR lpszHost, LPSTR ip)
{
LPHOSTENT lphost;
lphost = gethostbyname(lpszHost);
if (lphost == NULL)
{
*ip = NULL;
return WSAGetLastError();
}
SOCKADDR_IN sockAddr;
sockAddr.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr;
strcpy(ip,inet_ntoa(sockAddr.sin_addr));
return 0;
}
void main()
{
InitWinSock();
char szHost[256];
gethostname(szHost,sizeof(szHost));
char ip[16];
GetIpAddress(szHost,ip);
}
don't forget to link with Ws2_32.lib.
|
|
|
|
|
In script engine, I can use IActiveScript->AddNamedItem() to add a root level item. But how to add a 2nd level named item ?
I can add the root level "Application", but I don't know how to add a second level "Documents" to "Application".
Does anyone know ?
Is it only first level item can have event ?
Thanks
|
|
|
|
|
The second level is accessible via the first levels IDispatch interface - i.e. if you have a Documents property, you could use Application.Documents in script. The script engine uses your IActiveScriptSite interface to get Application , then calls into Application to get Documents .
As for events...I believe the following should work (I'm assuming VBScript and an event called DoSomething )
Dim event_raiser
Sub event_raiser_DoSomething
some code
End Sub
Set event_raiser = Application.Documents
some more code, which causes DoSomething to be raised
I think you can handle events from any object you can reference like that. I'm not sure how you hook up events in JScript, but I guess the same is true.
<after looking @ MSDN>
It appears you can use a function of the form object_variable_name::event_name (which is like the VB example above) or something like object.event = function pointer , which I've never used, but sounds like it doesn't use
IConnectionPoint et. al. I'm not sure - does anyone know for sure?<br />
<code></after looking @ MSDN>
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
I am successfully conecting to *.mdb database on my local machine using following connection string:
HRESULT hr = m_pConnection->Open(
_bstr_t(L"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\source\\VCDb.mdb;"),
_bstr_t(L""),
_bstr_t(L""),
NULL);
Now i want to connect to SQL-Server running on the machine in my neighbourhood. The ip of target machine is 192.168.10.10. Plz tell me the connection string.
|
|
|
|
|
|
I don't know whether this is a correct forum to ask this question..Anyways.
I place certain font file in the windows fonts directory. It gets automatically register in the registry. At that time my application and other applications properly loads the font. But sometimes font automatically disappeaared both from fonts directory and registry especially when i restart my computer. Sometime when i refresh the fonts folder, the font appears again and related applications starts loading it normally. Can anyone tell me whats the problem
|
|
|
|
|
I have a char* buffer pBuf filled with a bitmap. I want to get the size of the bmp from this buffer so I see that I need stuff like:
BITMAPINFOHEADER &bmiHeader = *(LPBITMAPINFOHEADER)(what goes here?);
BITMAPINFO &bmInfo = *(LPBITMAPINFO)(what goes here?);
Thanks,
ns
|
|
|
|
|
pBuf
WWJD? JWRTFM. found on /.
|
|
|
|