|
I don't know why.
DeviceIoControl() is a Windows kernel function that passes the request to the device specific driver. So there should be no differences on one machine when calling this from a VS 2003 or VS 2008 generated application or even any other programming language.
|
|
|
|
|
Simple answer use VS2008 or later.
Use the best guess
|
|
|
|
|
you have a 30GB memory card? that's a strange size... they're sized in generally powers of two.
|
|
|
|
|
Chris Losinger wrote: you have a 30GB memory card? that's a strange size... they're sized in generally powers of two.
That's generally the case, but some lower capacity SSDs are specified in tens of gigs.
try googling for 30GB/40GB SSD.
|
|
|
|
|
here is the question I did ask before:
I have a listview REPORT with fullrowselect style everything works fine, but after i used customdraw I faced a problem such pic included, it seems I click on the item col 3 it becomes bold and more bold..
Picture[^]
if i use listview_update the bold text from the col 3 will be gone so why happens? and i just want to click on the raw without having that bold problem? any ideas?
The Code
if (lpNMHdr->code == NM_CUSTOMDRAW)
{
LPNMLVCUSTOMDRAW lpCD = (LPNMLVCUSTOMDRAW)lpNMHdr;
if (lpCD->nmcd.dwDrawStage == CDDS_PREPAINT)
{
return CDRF_NOTIFYITEMDRAW;
}
if (lpCD->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
{
return CDRF_NOTIFYSUBITEMDRAW;
}
if (lpCD->nmcd.dwDrawStage == (CDDS_ITEMPREPAINT|CDDS_SUBITEM))
{
if (lpCD->iSubItem == 0) {
LPCTSTR lpcszBuf1 = _T("example");
LPCTSTR lpcszBuf2 = _T("text");
RECT iR = { 0 };
ListView_GetSubItemRect(lpCD->nmcd.hdr.hwndFrom, lpCD->nmcd.dwItemSpec, lpCD->iSubItem, LVIR_BOUNDS, &iR);
SetBkMode(lpCD->nmcd.hdc, TRANSPARENT);
SIZE sz = { 0 };
GetTextExtentPoint32(lpCD->nmcd.hdc, lpcszBuf1, 7, &sz);
SetTextColor(lpCD->nmcd.hdc, RGB(255, 0, 0));
DrawText(lpCD->nmcd.hdc, lpcszBuf1, -1, &iR, DT_LEFT);
iR.left += sz.cx;
SetTextColor(lpCD->nmcd.hdc, RGB(0, 255, 0));
DrawText(lpCD->nmcd.hdc, lpcszBuf2, -1, &iR, DT_LEFT);
return CDRF_SKIPDEFAULT;
}
}
So someone answered me:
If you draw it yourself you need to clear the background as well, which you are not doing. Try using OPAQUE instead of TRANSPARENT.
However, I used OPAQUE but it does not help a lot so, I am trying now with clear the background: the message is wm_ERASEBACKGROUND but what I suppose to do? should I add the code there or what?
|
|
|
|
|
Just out of curiosity, why are you drawing the text yourself rather than using SetWindowText() ?JoneLe86 wrote: I click on the item col 3 it becomes bold and more bold.. I think either your X or Y coordinate is changing by 1 pixel each time. Without actually testing, that's just a guess, though.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
cuz I am coloring those buffers?!
|
|
|
|
|
Fair enough, but you can still use SetWindowText() (elsewhere, not in response to NM_CUSTOMDRAW ) rather than DrawText() for that.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
thanks for this info...
do you know what I should do? i still do get what i want, the more i click on them the more bold the become.....
|
|
|
|
|
JoneLe86 wrote: do you know what I should do? i still do get what i want, the more i click on them the more bold the become..... Check the X and Y coordinates to make sure they are the same each time your message handler is called.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
You must fill the cell rect with the background color before drawing the text. The CDC class provides the FillSolidRect() function which can be used to do this. When using DC handles, you can do it the same way as the CDC class:
::SetBkColor(lpCD->nmcd.hdc, GetBkColor());
::ExtTextOut(lpCD->nmcd.hdc, 0, 0, ETO_OPAQUE, &iR, NULL, 0, NULL);
|
|
|
|
|
Thanks for this info..
You must fill the cell rect with the background color before drawing the text.
SetBkColor(lpCD->nmcd.hdc, GetBkColor());
ExtTextOut(lpCD->nmcd.hdc, 0, 0, ETO_OPAQUE, &iR, NULL, 0, NULL);
but may function looks like this
fillrect(); //i am using this to fill out the specific rect
settextcolor(); //then I set the text color
Drawtext() //then I draw the text
(1)
if use ExtTextOut then there is no need to drawtext?
ExtTextOut(lpCD->nmcd.hdc, 0, 0, ETO_OPAQUE, &iR, Buffer, strlen(Buffer), NULL);
(2)
i used SetBkColor(lpCD->nmcd.hdc, GetBkColor(..)); nothing happened, i do not set a bk color in my listview, i did set a row color manually... so If I do SetBkColor(lpCD->nmcd.hdc, RGB(255,0,0)); the whole list bk changed to red?
maybe the method i use is wrong..
|
|
|
|
|
My example code is those used by CDC::FillSolidRect() . It will erase the cell using the actual background color of the HDC which can be set to the default returned by CListView::GetBkColor() or any other you are specifying (e.g. a row specific color).
You may of course use ExtTextOut() to print the cell text parts with different colors when adjusting the rect.
When using CListView::SetBkColor() this will set the default color for the list. When calling ::SetBkColor(HDC) , this specifies the color for the drawing functions using the HDC.
If you change the background color (or the text color) of the HDC, you should restore it to the original value that is returned by the first set call. Restoring the colors may be omitted when all cells are owner drawn.
|
|
|
|
|
OMG man (After all that Time) I finally got what I am looking for thanks so much..
those info helped me a lot

|
|
|
|
|
I have not tried using direct drawing code such as you do, but maybe this MSDN sample[^] will help.
Use the best guess
|
|
|
|
|
Hi
I am getting the above mentioned error when clearly DebugString is a member of _DEBUG_EVENT
My declaration of DEBUG_EVENT is as follows
DEBUG_EVENT debug_event;
|
|
|
|
|
If you check the documentation for the structure[^] you will see that DebugString is part of the union u . So to address this item you should code:
debug_event.u.DebugString;
debug_event->u.DebugString;
Use the best guess
|
|
|
|
|
I'm sorry yes you are
Right
|
|
|
|
|
Hello,
I have a problem with my Progress Bar in MFC, C++
Indeed, I want display progress bar in CList Ctrl. I use the class CProgressCtrl.
And I want to move this prograss bar if my scroll bar move. I use MoveWindow(...), RedrawWindow(...) functions.
It runs in mode Debug but in mode Release, it doesn't run, i've got an error with MoveWindow function because in this function, the program doesn't know the m_Wnd and m_pCtrlSite
Help me
|
|
|
|
|
I want to record d3d games. Now I can get data from backbuffer and save it.
The programe is when the game resize the window, I should strech it.
The following is my steps:
IRefPtr<ID3D10Texture2D> texture;
HRESULT hRes = m_pDXGISwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D),
reinterpret_cast<void**>(IREF_GETPPTR(texture,ID3D10Texture2D)));
if (FAILED(hRes))
{
return hRes;
}
hRes = pDevice->CreateTexture2D(&desc, NULL, IREF_GETPPTR(textureDest,ID3D10Texture2D));
if (FAILED(hRes))
{
return hRes;
}
pDevice->CopySubresourceRegion(textureDest, 0, 0, 0, 0, texture, 0, &sourceRegion);
Everything is ok, but as i say, when the game change size, i must stretch the Texture2D for get the whole picture. The CopySubresourceRegion() cant do it. And i dont find anyother way to do it.
Thanks for any advices. I am a newer for directx.
I am a rookie boy, if you help me, i will become a man.
|
|
|
|
|
I think the D3D10LoadTexureformTexure() will be the right answer. But it is very slow.It is not a best answer but a right one.
|
|
|
|
|
Hi everyone.
Recently i'm working on a project which is to record games. Some trouble comes to me, for d3d10 and d3d11. I can hook the Present() through IDXGISwapChain:
PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN1 pDirect3DCreate10 = (PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN1)GetProcAddress("D3D10CreateDeviceAndSwapChain1");
if (pDirect3DCreate10 == NULL)
{
return false;
}
IDXGISwapChain * pSwapChain;
ID3D10Device1 * pDevice;
HRESULT hRet = pDirect3DCreate10(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_FEATURE_LEVEL_9_1,
D3D10_1_SDK_VERSION, &swapChainDesc, &pSwapChain, &pDevice);
if (FAILED(hRet))
{
return false;
}
UINT_PTR* pVTable = (UINT_PTR*)(*((UINT_PTR*)pSwapChain));
m_nDX10_Present = pVTable[8];
m_nDX10_ResizeTarget = pVTable[14];
Using VTable to get the address. And I can save backbuffer. But when change game's size, the game will crash. It seems change size wouldn't go to ResizeTarget(). So I want to ask:
1. When the game change size for d3d10_1.dll, what does he do, and what should I do?
2. There is other question, when the game exit, what should i do. i want to stop my project when the game is exit.
Thanks for any advices. I'm a newer in directx. There are so many publishs for directx, i.e d3d9, d3dx9_43, d3d10, d3d10_1, d3d11, d3d11_1 and so on. 
modified 19-Jul-13 0:53am.
|
|
|
|
|
I find when resize game's window it will call IDXGISwapChain()->ResizeBuffers(). I can hook ResizeBuffers(). And it also crash(the game is stablish, cant move any more.).I dont konw what should i do? please help!
|
|
|
|
|
Hello,
I am trying to call a GUI function from a worker thread in a Doc/View application in MFC in VS2008. It was working fine on XP 32bit, but throws error in Windows 7 32bit.
I am calling the following function within a worker thread-
parent->UpdateAllViews(NULL);
The error that it throws is at Line 900 in wincore.cpp which is
ASSERT(pMap != NULL);
Also my other function which was working fine under XP is giving fatal error
AfxGetMainWnd()->PostMessage(WM_CLOSE, 0, 0);
The above function is also called in the same worker thread.
Any suggestions/ideas?
thanks
PKNT
|
|
|
|
|
Every normal gui framework is single threaded that means: you can access gui related data and functions only from the gui thread (that is the main thread in case of MFC). Its only blind luck that your app worked on WinXP most of the time. Multithreaded programs become quite non-deterministic and the same is true for the occurrence/reproduction of their bugs. Now you are "lucky" that you have a quite reliable repro case for your bug that was a bug even on WinXP!
1. AfxGetMainWnd() is a gui related call so I would call it only from the main/gui thread. Call AfxGetMainWnd() from the gui thread when you create the worker thread and pass the window pointer to the thread as a CreateParam. Since SendMessage() and PostMessage() are thread safe WinAPIs the same is true for the SendMessage() and PostMessage() methods of the window.
2. On the worker thread use the PostMessage() or SendMessage() method on the window pointer you received as a ThreadCreateParam. PostMessage(WM_CLOSE, 0, 0) should work if you use directly the window pointer without AfxGetMainWnd().
3. To call UpdateAllViews() do the following: Define your own window message. Either WM_APP+(0..1000 or whatever) or WM_USER+... Then use again PostMessage() on the window pointer to post your own window message. In the message map of your window receive your user defined message with ON_MESSAGE(WM_MYMESSAGE, OnMyMessageMethod). Your OnMyMessageMethod() will be called from the gui thread so it will be safe to call UpdateAllViews() from there. Use PostMessage() instead of SendMessage() if you don't want the worker thread to block until the end execution of OnMyMessageMethod() on the gui thread.
BTW: Here is the implementation of AfxGetMainWnd() of VS2010:
_AFXWIN_INLINE CWnd* AFXAPI AfxGetMainWnd()
{ CWinThread* pThread = AfxGetThread();
return pThread != NULL ? pThread->GetMainWnd() : NULL; }
If your worker thread was created with non-mfc api then this AfxGetMainWindow() returns NULL always if called from your worker thread.
|
|
|
|
|