Click here to Skip to main content
       

Windows API

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: endless WM_MOUSEWHEEL eventsmembered welch29 Dec '12 - 2:52 
no, it works fine. It is definately not hardware. I could be that one mouse is fly wheel and other is not, or it could be that the code I'm using is wrong in someway
GeneralRe: endless WM_MOUSEWHEEL eventsmemberEddy Vluggen29 Dec '12 - 3:37 
Could it be a "helpful hidden feature" of the mouse-driver? Smile | :)
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: endless WM_MOUSEWHEEL eventsmembered welch29 Dec '12 - 7:57 
Yes, but that would affect all applications, which it clearly isn't.
GeneralRe: endless WM_MOUSEWHEEL eventsmemberEddy Vluggen29 Dec '12 - 8:09 
No, it would not; some programmers would simply take the first message, and ignore the repeating drivel, just like you would with spurious wm_mousemove messages.
 
Update the drivers Smile | :)
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: endless WM_MOUSEWHEEL eventsmembered welch29 Dec '12 - 10:42 
Not really. There's no way to tell which are real events and which are the spurious ones. At least, there's no way I know.
GeneralRe: endless WM_MOUSEWHEEL eventsmemberSledgeHammer0129 Dec '12 - 12:16 
You haven't posted any code or shown what any of the "extra" WM_MOUSEWHEEL events you are getting look like and unfortunately, my crystal ball is in the shop, so you might want to post that kind of information. My guess is that its something in your code, but until I see the messages or your code, I can't really give you any advice beyond that. Darn crystal ball shop, they are taking FOREVER to get my ball fixed.
Questionwin32memberusermina122 Dec '12 - 21:17 
how write program paint in win32?
AnswerRe: win32mvpRichard MacCutchan22 Dec '12 - 23:47 
  1. Study the C/C++ languages.
  2. Learn the structure of Windows programs and how to create them.
  3. Study the Win32 API starting here.
  4. Decide on whether to use Windows GDI or GDI+.
  5. Design your application.
  6. Start coding.
One of these days I'm going to think of a really clever signature.

GeneralRe: win32memberSajeesh Payolam24 Dec '12 - 19:18 
You are absolutely right Richard Big Grin | :-D
AnswerRe: win32memberSajeesh Payolam24 Dec '12 - 19:16 
First you should study what is win32 programming. If you don't know about win32 programming, then how can coding win32 programs? so first study win32 APIs
http://www.winprog.org/tutorial/
 
Also see Richards comments
AnswerRe: win32memberProgramFOX28 Dec '12 - 4:33 
Hi,
 
This is an article that can help you:
Guide to WIN32 Paint for beginners[^]
It doesn't explain how to create a Paint program, but how to paint shapes in your form.
In some cases, my signature will be longer then my message...
<em style="color:red">ProgramFOX</em>
ProgramFOX

AnswerRe: win32memberPravinda Amarathunge8 Jan '13 - 0:27 
Follow the Book "Programming Windows 5th Edition - Charles Petzold"
GeneralRe: win32memberpasztorpisti20 Jan '13 - 1:37 
my5
AnswerRe: win32memberStephen Hewitt19 Mar '13 - 16:21 
May as well be asking how to skin a cat.
 
Steve

QuestionMicrosoft Media Foundation - Replacing Time Source / ClockmemberMember 941190620 Dec '12 - 10:03 
I want to playback videos with Microsoft Media foundation with a custom clock.
 
I am starting with the example found at http://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=mediafoundation&DownloadId=8413[^]
 
The idea is to replace the clock with one that is driven by UDP packets. The videos will be silent (the audio turned off, preferably not even decoded).
 
I have stubbed out what I think is a clock replacement, but what I can't figure out is why my calls to GetCorrellatedTime seem to only occur at the start of playback. I expected GetCorrellatedTime to be called by the playback engine repeatedly.... but that's just not happening. Here's the cpp code for my timesource. Note that it doesn't do much of anything yet... it is just a stub.
 
Any Ideas? Thanks in advance
 
 
#include "MFPlayer.h"
#include "TimeSource.h"
 

 
HRESULT STDMETHODCALLTYPE UDPClock::GetClockCharacteristics( /* [out] */ __RPC__out DWORD *pdwCharacteristics)
{
	*pdwCharacteristics = MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ;
	return S_OK;
}
        
HRESULT STDMETHODCALLTYPE UDPClock::GetCorrelatedTime( /* [in] */ DWORD dwReserved,/* [out] */ __RPC__out LONGLONG *pllClockTime,/* [out] */ __RPC__out MFTIME *phnsSystemTime)
{
	m_Time = GetTickCount64();
	m_System_Time = GetTickCount64();
 
	*pllClockTime = m_Time;
	*phnsSystemTime = m_System_Time;
	return S_OK;
}
        
HRESULT STDMETHODCALLTYPE UDPClock::GetContinuityKey( /* [out] */ __RPC__out DWORD *pdwContinuityKey)
{
	*pdwContinuityKey = 0;
	return S_OK;
}
        
HRESULT STDMETHODCALLTYPE UDPClock::GetState( /* [in] */ DWORD dwReserved,/* [out] */ __RPC__out MFCLOCK_STATE *peClockState)
{
	*peClockState = MFCLOCK_STATE_RUNNING;
	return S_OK;
}
        
HRESULT STDMETHODCALLTYPE UDPClock::GetProperties( /* [out] */ __RPC__out MFCLOCK_PROPERTIES *pClockProperties)
{
	pClockProperties->qwCorrelationRate = 1000000;
	pClockProperties->guidClockId = GUID_NULL;
	pClockProperties->qwClockFrequency = MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ;
	pClockProperties->dwClockTolerance = MFCLOCK_TOLERANCE_UNKNOWN;
	pClockProperties->dwClockJitter = 1;//10000;
	pClockProperties->dwClockFlags = MFCLOCK_RELATIONAL_FLAG_JITTER_NEVER_AHEAD;
 
	return S_OK;
}
 
HRESULT STDMETHODCALLTYPE UDPClock::GetUnderlyingClock(/* [out] */ __RPC__deref_out_opt IMFClock **ppClock)
{
	*ppClock = this;
	return S_OK;
	//return this;
	//return this->QueryInterface<IMFClock>(ppClock);
}
 

HRESULT UDPClock::QueryInterface (REFIID   riid, LPVOID * ppvObj)
{
    // Always set out parameter to NULL, validating it first.
    if (!ppvObj)
        return E_INVALIDARG;
    *ppvObj = NULL;
	if (riid == IID_IUnknown || riid == IID_IMFClock || riid == IID_IMFPresentationClock)
		return NOERROR;
    
    return E_NOINTERFACE;
 
}
//--------------------------------------------------------------------------------------------------------------------------------
ULONG UDPClock::AddRef()
{
    InterlockedIncrement(&m_cRef);
    return m_cRef;
}
//--------------------------------------------------------------------------------------------------------------------------------
ULONG UDPClock::Release()
{
    // Decrement the object's internal counter.
    ULONG ulRefCount = InterlockedDecrement(&m_cRef);
    if (0 == m_cRef)
    {
        delete this;
    }
    return ulRefCount;
}
//--------------------------------------------------------------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE UDPClock::OnClockStart( /* [in] */ MFTIME hnsSystemTime,/* [in] */ LONGLONG llClockStartOffset)
{
	return S_OK;
}
//--------------------------------------------------------------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE UDPClock::OnClockStop( /* [in] */ MFTIME hnsSystemTime)
{
	return S_OK;
}
//--------------------------------------------------------------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE UDPClock::OnClockPause( /* [in] */ MFTIME hnsSystemTime)
{
	return S_OK;
}
//--------------------------------------------------------------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE UDPClock::OnClockRestart( /* [in] */ MFTIME hnsSystemTime)
{
	return S_OK;
}
//--------------------------------------------------------------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE UDPClock::OnClockSetRate( /* [in] */ MFTIME hnsSystemTime,/* [in] */ float flRate)
{
	return S_OK;
}
//--------------------------------------------------------------------------------------------------------------------------------

 

 


Questionprinting vertical text using ExtTextOut in memory DCmemberabrahamlincolng13 Dec '12 - 1:06 
I am using ExtTextOut to print unicode characters in memory DC. We create font using CreateFontIndirect to print characters in different orientations. When we use GB2312_CHARSET (chinese character set) with lfEscapement/orientation set to 270 degrees the characters are printed in reverse order.
If the character to be printed is 'Chinese', it is printed as 'esenihc'. The same character set works fine if lfEscapement/orientation is set to 0 deg.
The issue is present only in WINCE. The same code works fine in a Win32 application.
I have written a sample application.Find below the code from sample app
 
CSampView::OnDraw (CDC* pDisplayDC)
{
 
HDC hDC = CreateCompatibleDC(NULL);
HBITMAP hBmp = CreateCompatibleBitmap(hDC, width, height);
BITMAPINFO	biBitmapInfo;
 
// font size may vary if screen resolution changes
biBitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
biBitmapInfo.bmiHeader.biWidth = 500;
biBitmapInfo.bmiHeader.biHeight = 500;
biBitmapInfo.bmiHeader.biPlanes = 1;
biBitmapInfo.bmiHeader.biBitCount = 1 ;
biBitmapInfo.bmiHeader.biCompression = BI_RGB;
biBitmapInfo.bmiHeader.biSizeImage = 0;
biBitmapInfo.bmiHeader.biXPelsPerMeter = 0;
biBitmapInfo.bmiHeader.biYPelsPerMeter = 0;
biBitmapInfo.bmiHeader.biClrUsed = 0;
biBitmapInfo.bmiHeader.biClrImportant = 0;
biBitmapInfo.bmiColors[0].rgbBlue = 0;
biBitmapInfo.bmiColors[0].rgbGreen = 0;
biBitmapInfo.bmiColors[0].rgbRed = 0;
biBitmapInfo.bmiColors[1].rgbBlue =1;
biBitmapInfo.bmiColors[1].rgbGreen = 1;
biBitmapInfo.bmiColors[1].rgbRed = 1;
 
CDC *pDC = CDC::FromHandle(hDC);
/*TCHAR szString[255] = {0x0043, 0x0068, 0x0069, 0x006E, 0x0065, 0x0073, 0x0065, 0x003A, 0x0020, 0x96C5,
		 0x864E, 0x641C, 0x661F, 0x575A, 0x51B3, 0x5426, 0x8BA4, 0x80E1, 0x6208, 0x63A5,
		 0x62CD, 0x96C5, 0x864E, 0x5E7F, 0x544A };*/
 

wchar_t szString[255] = _T("Print Test");
 
PUINT8 pui8ImageContent;
// Create rendering canvas
HBITMAP	hBmp1	= CreateDIBSection(hDC,
										   &biBitmapInfo,
										   DIB_PAL_COLORS,
										   (void**)&pui8ImageContent,
										   NULL,
										   0);
 
HBITMAP holdObj = (HBITMAP)SelectObject(hDC, hBmp1);
if (NULL == holdObj)
{
	AfxMessageBox(L"Bitmap Selection failed");
}
CBitmap* aBMP = CBitmap::FromHandle(hBmp);
BITMAP* abmpDim = NULL;
aBMP->GetBitmap(abmpDim);
 
memset(pui8ImageContent, 0, m_iOverallSizeInBytes);
 

LOGFONT	SLogFont	= {0};
memset(&SLogFont, 0, sizeof(LOGFONT));
SLogFont.lfHeight 	= 50;
SLogFont.lfWidth 	= 50;
SLogFont.lfCharSet 	= GB2312_CHARSET /*HANGUL_CHARSET*//*DEFAULT_CHARSET*/;
 
SLogFont.lfEscapement  	= 2700;
SLogFont.lfOrientation 	= 2700;
 
SLogFont.lfItalic 	= FALSE;
SLogFont.lfUnderline 	= FALSE;
SLogFont.lfStrikeOut 	= FALSE;
SLogFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
SLogFont.lfClipPrecision  = CLIP_DEFAULT_PRECIS;
SLogFont.lfQuality 	  = DEFAULT_QUALITY;
SLogFont.lfPitchAndFamily = VARIABLE_PITCH|FF_ROMAN;
wcscpy(SLogFont.lfFaceName,_T("@Simsun"));
 
HFONT	hChFont	= CreateFontIndirect(&SLogFont);
 

if (NULL == hChFont)
{
	AfxMessageBox(L"Font Creation failed");
}
 
CFont* pFont = pDC->GetCurrentFont();
	HFONT hFont = (HFONT)SelectObject(hDC, hChFont);
 
if (NULL == hFont)
{
	AfxMessageBox(L"Font selection failed");
}
 

BOOL aStringWtitten = ExtTextOut(
		hDC, 			// Rendering canvas
		SSize.cy + iVerStartBit + 50,	// x-offset 
		100,			// y-offset
		ETO_OPAQUE,
		NULL,
		szString, 					
		wcslen(szString), 
		NULL);
 
if (false == aStringWtitten)
{
	AfxMessageBox(_T("Write text failed"));
}
 
BitBlt(pDisplayDC->GetSafeHdc(),50, 0, 500, 500, hDC, 0, 0, SRCCOPY);
 
}

AnswerRe: printing vertical text using ExtTextOut in memory DCmemberabrahamlincolng13 Dec '12 - 20:22 
Have i asked the question in a wrong forum Confused | :confused:
GeneralRe: printing vertical text using ExtTextOut in memory DCmemberEddy Vluggen20 Dec '12 - 2:10 
Nope, this is the correct forum; but your question might be a bit too advanced for most of us. I'd be looking for an alternative by now, like painting the text on a bitmap and rotate that.
 
Did you solve your problem? If yes, how?
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: printing vertical text using ExtTextOut in memory DCmemberpasztorpisti21 Dec '12 - 21:23 
I guess this is a bug, its not uncommon. Especially because the win32 (more maintained) sibling works well.
QuestionFork Implementation using the native API RtlCloneUserProcessmemberakhilmv889 Dec '12 - 4:02 
Hi,
I tried to port the fork API in Linux to Windows (Windows 7 and Windows 8) using the native API RtlCloneUserProcess as discussed in the following link.
http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/afdf1b68-1f3e-47f5-94cf-51e397afe073/
With the RtlCloneUserProcess function, child process is created, but didn’t get the console handle, stdin, stdout etc. The solution is to inform the CSR /win32 subsystem about the new process. But I could not able to do that. Please help me to re link the child process to the CSR.
AnswerRe: Fork Implementation using the native API RtlCloneUserProcessmemberEddy Vluggen9 Dec '12 - 6:26 
akhilmv88 wrote:
With the RtlCloneUserProcess function, child process is created, but didn’t get the console handle, stdin, stdout etc.

I see more risks; an app locking a file that gets forked, will be in trouble.
 
akhilmv88 wrote:
The solution is to inform the CSR /win32 subsystem about the new process.

I did not see that "solution" in the thread you linked.
 
akhilmv88 wrote:
But I could not able to do that.

Include the error-message, or at least the return-value.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: Fork Implementation using the native API RtlCloneUserProcessmemberakhilmv889 Dec '12 - 17:17 
In the link it is given that “For the console, you do need to re-establish a link to csrss, but the setup is only done in ntdll if the CsrPort handle is NULL. This isn't the case in the forked process which of course, has the parent processes handle value. Nowhere in ntdll sets it to back to NULL so there's no chance of getting that to work unless you d/l the ntdll symbols, find where the handle is, and NULL it out yourself.”
Also on further analysis on the CRS, it is understood that CSRSS is responsible for Win32 console handling. The link, http://translate.google.co.in/translate?hl=en&sl=ru&u=http://www.wasm.ru/forum/viewtopic.php%3Fid%3D42246&prev=/search%3Fq%3DCsrClientCallServer%26hl%3Den%26tbo%3Dd%26biw%3D991%26bih%3D598&sa=X&ei=e17FUNP7NMrtrQeA7IFo&ved=0CGAQ7gEwBg , gave some idea to manually notify the CSR about the new process, but I could not able to do that in windows 7.
The CsrClientCallServer function returns a negative value and the data buffer to the api CsrClientCallServer got corrupted after the call.
GeneralRe: Fork Implementation using the native API RtlCloneUserProcessmemberEddy Vluggen9 Dec '12 - 22:53 
Not a word on that function in MSDN. CsrClientCallServer is an undocumented (internal) function, and it's fingerprint may vary without warning.
 
Sorry, can't help here.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

QuestionCustom item in context menumemberdevboycpp4 Dec '12 - 0:46 
How can an item be added to context menu that pops up when highlighting a part of text in any program and right clicking ? And a code should be associated with that which processes the piece of text highlighted. The item should be added to every programs context menu when text can be selected;ex Internet Explorer , Firefox , notepad, etc...
I have some general methods in my mind from my studies revolving around windows internals. But no specifics.
 
What is the best way to do it ? can this be done by writing code in kernel mode ? how ? is it necessary ? what are other methods which involve user mode programming ?
AnswerRe: Custom item in context menumvpRichard MacCutchan4 Dec '12 - 4:55 
You cannot add items to every context menu on the system; not all of them are dynamic. You can add to Windows Explorer and (probably) IE by writing extensions or via other published interfaces. Try a Google search for samples and articles on the subjects.
One of these days I'm going to think of a really clever signature.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 12 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid