|
Yes, I used (Void*)&hCombo and HWND hCombo = (HWND)lpContext as this was how it was written in the MSDN explanatory code snippets.
I think I understand what you mean though.
lpContext is a pointer which contains the address of hCombo when I pass it, so I need to dereference lpContext when I'm initializing the local hCombo in the callback, right?
I've tried HWND hCombo = (HWND)*lpContext; but the IDE says "Error: expression must be a pointer to a complete object type". Is it incorrect to declare, dereference, cast and initialize all in the one statement?
Thank you again.
Paul
|
|
|
|
|
Actually, it would be simpler to just keep your callback code the same, and write (Void*)hCombo . A HWND will fit into a pointer-size variable, which is what lpContext is. So keep the callback like you had it before: HWND hCombo = (HWND)lpContext;
|
|
|
|
|
Thanks Hans. It works.
I think I took MSDN's description of DirectSoundEnumerate too literally.
It says:
HRESULT DirectSoundEnumerate(
LPDSENUMCALLBACK lpDSEnumCallback,
LPVOID lpContext
)
Parameters
lpDSEnumCallback
Address of the DSEnumCallback function that will be called for each device installed in the system.
lpContext
Address of the user-defined context passed to the enumeration callback function every time that function is called.
So I assumed lpContext had to be a pointer, but since it's just being passed straight on to the callback function anyway, I guess it doesn't have to be.
Your help is greatly appreciated.
Best regards
Paul
|
|
|
|
|
Good ol' MSDN. God's gift to consultants.
BTW, Petzold was how I learned Win32 too. If you get tired of dealing with all that wndproc stuff, check out MFC; it's a very thin wrapper over Win32, and makes a lot of things easier.
Good luck.
|
|
|
|
|
THX 
|
|
|
|
|
google for "file associations".
|
|
|
|
|
Hello,
I need to write simple application which will have main interface in default screen, which will be able to redirect just an output (simple animation) to the separate video output port (HDMI or DVI).
I want to use GDI+ to do that, however I don’t know how to obtain the DC of the output device.
I will be grateful for your advices or any articles about that.
Thank you a lot,
B.
|
|
|
|
|
Try this:
1. Use EnumDisplayMonitors[^] to enumerate the displays.
2. In the callback method ( MonitorEnumProc[^] ), use GetMonitorInfo[^] with MONITORINFOEX[^] to get the device name for the monitor (szDevice member)
3. Use CreateDC[^], specify "DISPLAY" for the lpszDriver parameter, the device name you got in step 2 for the lpszDevice parameter and NULL for the rest.
Of course you will want to filter out the one monitor/device you want to use. Hope this can direct you in the right direction.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Thank you a lot, this is exactly what I needed.
B
|
|
|
|
|
Yourwelcome.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Hello every one I have to draw red mark line in to list control having grid view to show invalidate entry Can any one tell how to draw it
|
|
|
|
|
Hi
You need to handle ListView custom draw and draw the line using the Device Context.
Find ListView custom draw article in code project.
Nitheesh George
http://www.simpletools.co.in
|
|
|
|
|
Thanks nitesh,
Rightnow I show rectangle having invalid entry with background color in custdraw but insted of background color I want to show line on that entry. So what I can do for it....
|
|
|
|
|
You need to handle the custom draw notification and draw the whole item in the control, using GDI (or GDI+) API calls.
For entries that are invalid, you can then draw a red line though then using MoveTo/LineTo.
For an example of a ListView custom draw, read this article[^]
EDIT: This article might be better that the C# one I originally posted... Using ListView control under Win32 API[^]
|
|
|
|
|
Hi all,
i m trying to read a Text file using CStdioFile,but this is fail and read some garbage values whan the file is encoded with other than ANSI format like Unicode,UTF-8 etc.
please tell me before start reading how can i identify the file is not in ANSI format.
i m waiting for ur valuable suggestions.
thanks in advance.
|
|
|
|
|
It depends,
For some file formats there is no way to tell them apart programatically (e.g. Chinese Big5 vs. Ansi).
I imagine you are more interested in unicode specifically, though. For Unicode files there is normally a BOM (byte order mark) at the beginning of the file which tells you what the file format is. Look up Byte order marks on wikipedia for a really good explanation.
Alternatively if you don't want to do this by hand, read this article[^] for a CStdiofile derived class that auto-detects the encoding.
|
|
|
|
|
See here[^] for explanations of how to identify different encoded files.
|
|
|
|
|
I use this way to read the binary buffers from the SQL's image field type.
the m_pBuffer's value is 0xFF all the same int the Debug Mode / Watch.
But I use the SQL Query Analyzer, it can be found. why is it ?
the filed info:
Version varchar(100)
Buffer image(16)
the code fragment:
BOOL CTestDlg::ReadBinary()
{
try
{
OleInitialize(NULL);
CString strTemp = _T("");
CString strDat = _T("");
CString strVer = _T("");
char *pBuf = NULL;
_bstr_t bstrsource = "select * from db_somedatease";
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open(bstrsource,_variant_t((IDispatch*)m_pConnection,TRUE),adOpenStatic,adLockOptimistic,adCmdText);
m_pRecordset->MoveFirst();
while(VARIANT_FALSE == m_pRecordset->adoEOF)
{
HANDLE m_hFile = INVALID_HANDLE_VALUE;
HANDLE m_hMapping = INVALID_HANDLE_VALUE;
DWORD m_dwSize = 0;
char *m_pSrc = NULL;
char *m_pBuffer = NULL;
_variant_t vtVer = m_pRecordset->GetCollect("Version");
VARIANT varBLOB;
strVer = VariantToCString(vtVer);
strTemp.Format(_T("%s\\Dat\\%s.tmp"),GetExePath(),strVer);
m_dwSize = m_pRecordset->GetFields()->GetItem("Buffer")->ActualSize;
if (m_dwSize > 0)
{
m_hFile = CreateFile(strTemp,GENERIC_ALL,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(m_hFile == INVALID_HANDLE_VALUE)
{
CString strError = _T("");
strError.Format(_T("CreateFile Failed!Error Code: %d"),GetLastError());
::MessageBox(NULL,strError,NULL,NULL);
return FALSE;
}
m_hMapping = CreateFileMapping(m_hFile,NULL,PAGE_READWRITE,0,m_dwSize,NULL);
if(m_hMapping == NULL)
{
CString strError = _T("");
strError.Format(_T("CreateFileMapping Failed!Error Code: %d"),GetLastError());
::MessageBox(NULL,strError,NULL,NULL);
CloseHandle(m_hFile);
return FALSE;
}
m_pSrc = (char *)MapViewOfFile(m_hMapping,FILE_MAP_ALL_ACCESS,0,0,0);
if(m_pSrc == NULL)
{
CString strError = _T("");
strError.Format(_T("MapViewOfFile Failed!Error Code: %d"),GetLastError());
::MessageBox(NULL,strError,NULL,NULL);
CloseHandle(m_hMapping);
CloseHandle(m_hFile);
}
memset(m_pSrc,0xFF,m_dwSize);
VariantInit(&varBLOB);
varBLOB = m_pRecordset->GetFields()->GetItem("Buffer")->GetChunk(m_dwSize);
if(varBLOB.vt == (VT_ARRAY | VT_UI1))
{
if(m_pBuffer = new char[m_dwSize + 1])
{
memset(m_pBuffer,0x00,m_dwSize);
SafeArrayAccessData(varBLOB.parray,(void **)m_pBuffer);
memcpy(m_pSrc,m_pBuffer,m_dwSize);
UnmapViewOfFile(m_pSrc);
CloseHandle(m_hMapping);
CloseHandle(m_hFile);
SafeArrayUnaccessData(varBLOB.parray);
delete [] m_pBuffer;
m_pBuffer = NULL;
}
}
}
m_pRecordset->MoveNext();
}
}
catch (_com_error e)
{
CString errormessage;
errormessage.Format("read version error!\r\n\r\nerror code:『%s』",e.ErrorMessage());
AfxMessageBox(errormessage);
return FALSE;
}
return TRUE;
}
if I use this way to read ,it is normal.
if(varBLOB.vt == (VT_ARRAY | VT_UI1))
{
memcpy(m_pSrc,varBLOB.parray->pvData,m_dwSize);
UnmapViewOfFile(m_pSrc);
CloseHandle(m_hMapping);
CloseHandle(m_hFile);
SafeArrayUnaccessData(varBLOB.parray);
VariantClear(&varBLOB);
}
because it doesn't use the SafeArrayAccessData, but is this way safety ?
thansk for your reply !
Best Regards !
modified on Friday, April 8, 2011 10:46 PM
|
|
|
|
|
Hi ,
I have created a shared memory using CreateSharedMemory () and mapping is done using MapViewOfFile () API. Is it possible to map only some part of Shared Memory? Does DWORD dwOffSetHigh and DWORD dwOffsetLow (i.e 3rd and 4th Parameter of MapViewOfFile () Method) need to be modified considering Allocation Granularity. Currently I can see the System granularity as 65535 using GetSystemInfo ().
Thanks
|
|
|
|
|
The offset values are a 64-bit value split into two 32-bit ones, and as far as I know, can map any portion of a file. Did you encounter any problems?
|
|
|
|
|
what are the valid registry setting for calling CoCreateInstanceAsAdmin()?
Regards,
Vishal
|
|
|
|
|
|
consulted but still no success.
when using CLSCTX_INPROC_SERVER CoCreateInstance() returns S_OK
but when using CLSCTX_LOCAL_SERVER CoCreateInstance() Fails.
Regards,
Vishal
|
|
|
|
|
vishalgpt wrote: Fails.
That does not help much; tell us what failure you see, try looking up the meaning of any error codes you get.
|
|
|
|
|
HRESULT hr = CoCreateInstance(CLSID_CExample,NULL,CLSCTX_LOCAL_SERVER,IID_CExample,(void**)&inf);
hr value is E_NOINTERFACE
No Such Interface Supported.
But if CLSCTX_INPROC_SERVER is used then the value of hr is S_OK
sorry for posting twice.
Regards,
Vishal
|
|
|
|
|