|
Thanks for the reply mark, I'm passing a LPWSTR into a function which accepts a LPCWSTR, here's my code:
TCHAR szFile[_MAX_PATH];
HANDLE test;<br />
<br />
ZeroMemory(&ofn, sizeof(ofn));<br />
ofn.lStructSize = sizeof(ofn);<br />
ofn.hwndOwner = mainLoop.hWnd;<br />
ofn.lpstrFile = szFile;<br />
ofn.lpstrFile[0] = '\0';<br />
ofn.nMaxFile = sizeof(szFile);<br />
ofn.lpstrFilter = _T("All\0*.*\0Text\0*.TXT\0");<br />
ofn.nFilterIndex = 1;<br />
ofn.lpstrFileTitle = NULL;<br />
ofn.nMaxFileTitle = 0;<br />
ofn.lpstrInitialDir = NULL;<br />
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;<br />
<br />
<br />
if (GetOpenFileName(&ofn)==TRUE) <br />
test = CreateFile(ofn.lpstrFile, GENERIC_READ,<br />
0, (LPSECURITY_ATTRIBUTES) NULL,<br />
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,<br />
(HANDLE) NULL);<br />
<br />
<br />
if (FAILED (D3DXGetImageInfoFromFile(szFile, &Info))){<br />
OutputDebugString("Failed to load image info");<br />
}
I've tried everything I can think of, I've a fairly good understanding of UNICODE and ANSI encoding and I can't see where I'm going wrong. Any help would be really a life saver. Would it be possible for me to send you all my code incase I'm making a mistake else where and just can't see it?
Oh and if I call this with D3DXGetImageInfoFromFile(_T("F:\\Pictures\\ShannonTrip2006-PrintRun\\ShannonTrip2006 326.jpg"), &Info) it works fine.
|
|
|
|
|
Hmm looks ok to me.
Try MAX_PATH instead of _MAX_PATH (should be == 260)
If you put a breakpoint after the call to GetOpenFileName() what is the contents of szFile[]?
Mark
|
|
|
|
|
MAX_PATH or _MAX_PATH is no problem, I've just never used _MAX_PATH
Where is it failing??
Mark
|
|
|
|
|
Its failing in the DirectX call, it just returns an error code stating invalid call which according to the api means its a bad parameter. It works if I just directly input the literal using _T("")
|
|
|
|
|
BarryOg wrote: It works if I just directly input the literal using _T("")
Ok.
Use the debugger to stop on (that is just before) the call and look at the string.
If it is not OK, try again with the brekpoint set right where the variable is set.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Ok...
If you put a breakpoint after the call to GetOpenFileName() what is the contents of szFile[]?
Mark
|
|
|
|
|
I almost forgot...
Be careful with this line...
ofn.nMaxFile = sizeof(szFile);
It should be
ofn.nMaxFile = sizeof(szFile) / sizeof(TCHAR);
or
ofn.nMaxFile = _MAX_PATH;
ofn.nMaxFile should be set to the maximum number of characters, not bytes.
This change will make it correct for both UNICODE and non-UNICODE compilation.
Mark
|
|
|
|
|
Hello everybody,
I have some question about Visual c++.net ,as follows:
first , how to reset pixel of picture control .
second , how to catch mouse i picture control .
please help me solve these problem ,think you .
|
|
|
|
|
hi!
use Invalidate() function to reset pixel of picture control.
Zo.Naderi-Iran
|
|
|
|
|
I'm sorry , I still can't understand your meaning ,because I don't know how to reset pixel use Invalidate(). I have tried to do like as follows:
1.set a variable(m_map) to picture control ,then do like this:
BITMAP bm;
bm.bmWidth=3600;
m_map.SetBitmap(bm);
but the soft can't be passed , because bm is not HBITMAP .
2. CWnd* pWnd = GetDlgItem(IDC_COORD);
pWnd->GetWindowRect(&rect);
rect.left=0;
rect.right=3600;
m_map.Invalidate();
It is no use , please help me , think you very much .
hansen
|
|
|
|
|
you call LoadBitmap for your control variable.
m_map.LoadBitmap(idBitmap)
idBitmap is your bitmap resource.
or
in picture control properies; you select Bitmap in Type combo and select your bitmap id in Image combo.
excusme if my answer isn't complate.
Zo.Naderi-Iran
|
|
|
|
|
but I only want to draw some line into picture control ,so it is no bitmap resource , I want to draw a line each 1 second (total is 60min),could you help me solve this problem?
|
|
|
|
|
but I only want to draw some line into picture control ,so it is no bitmap resource , I want to draw a line each 1 second (total is 60min),could you help me solve this problem?
Hansen
|
|
|
|
|
test using of CDC class.
CDC* pDC;<br />
pDC = GetDC();
and other members of CDC Class (MoveTo(), LineTo())
and final call invalidate() function for redraw controls.
Zo.Naderi-Iran
|
|
|
|
|
It's pervfect,i think use this way to draw line , it's no problem , but in the fact ,at the same time, I want to get point value in line by mouse .so I have to modify pixel .can you help me? very very thanks.
Hansen
|
|
|
|
|
I don't understand your problem exactly.
may write your code?
Zo.Naderi-Iran
|
|
|
|
|
my soft mainly function is communication and exchange parameters between PC and microprocessor . when PC get temperature value form microprocessor , It need display (one by one,each drop connect with line),and at the same time , I can catch some drop value form interface by mouse , if I don't reset the pixcel of picture control , it is very difficult to get a drop's situation by mouse ,so it can't get the drop value .
I draw line like as follows, if I only need draw line , I think this way is no problem, but I need catch one drop . so i don't know how to do .
CWnd* pWnd = GetDlgItem(IDC_COORD); //picture control ID
pWnd->GetWindowRect(&rect);
float mtd;
CString m_str;
int m_X,m_Y;
//==============interface display-------------------------
extern int CString_to_Int(CString *m_str,int *m_value);
CString_to_Int(&m_strX,&m_X);
CString_to_Int(&m_strY,&m_Y);
m_X=m_X-rect.left-30;
m_Y=m_Y;//-rect.top;
//=================================================================
pWnd->GetClientRect(&rect);
// create brush pencil object
pDC->SetBkMode(TRANSPARENT)
pDC->Rectangle(&rect);
m_left = rect.left+30 ;
m_top = rect.top+60 ;
m_right = rect.right-10 ; // right distance
m_bottom = rect.bottom-20 ; //画图区(刻度线)离低边框的距离
int m_IntervalPan = (m_right - m_left)/11; //共分n-1大格
m_Y=m_bottom-m_Y-47;
//m_X=m_X *m_IntervalPan/(m_Interval);//m_X*3600/(m_right-m_left);
if (m_IntervalPan < 1 ) m_IntervalPan =1;
// 创建画笔对象
//---------------Black---------------------------------------
CPen* pPenBlack = new CPen;
// Black画笔
pPenBlack->CreatePen(PS_SOLID,1,RGB(0,0,0)); //
//-------------Gray-------------------------------------------
CPen* pPenGray = new CPen;
pPenGray->CreatePen(PS_DOT,1,RGB(200,200,200)); //
//---------------PenMouse---------------------------------------------
CPen* pPenMouse = new CPen;
pPenMouse->CreatePen(PS_DOT,1,RGB(192,192,192)); //
//-------------Red-------------------------------------------
CPen* pPenRed = new CPen;
// 红色画笔
pPenRed->CreatePen(PS_SOLID,1,RGB(255,0,0));
//--------------------------------------------------------
// 创建画笔对象
CPen* pPenBlue = new CPen;
// 蓝色画笔
pPenBlue->CreatePen(PS_SOLID,1,RGB(0,0, 255));
//----------------------------------------------------------
// 创建画笔对象
CPen* pPenGreen = new CPen;
// 绿色画笔
pPenGreen->CreatePen(PS_SOLID,1,RGB(0,255,0));
//----------------------------------------------------------
// 选中当前Black画笔,并保存以前的画笔
CGdiObject* pOldPen = pDC->SelectObject(pPenBlack);
// 绘制坐标轴
pDC->MoveTo(m_left,m_top);
// 垂直轴
pDC->LineTo(m_left,m_bottom);
// 水平轴
pDC->LineTo(m_right,m_bottom);
// 写X轴刻度值
for (i = 0; i <=m_Xwidth; i += 600)
{
if(i==m_Xwidth)
{
str.Format(_T("%d 时间(分)"),(i/60));
}
else
{
str.Format(_T("%d"),(i/60));
}
pDC->TextOut(m_left+(i-40-m_Low)*m_IntervalPan/m_Interval,m_bottom+3,str);
}
// 写Y轴刻度值
for (i = 1000; i <=m_Yhigh; i += 1000)
{
str.Format(_T("%d"),(i/100));
pDC->TextOut((m_left+5),(m_bottom-i * (m_bottom - m_top) /m_Xwidth-7),str);
}
str=_T("位移(毫米)");
pDC->TextOut((m_left+5),(m_top),str);
//---------------------------------------------------------------------
// 绘制X轴刻度
for (i = 60; i <=m_Xwidth; i += 60)
{
if((i%600)==0)
{
// 10的倍数
pDC->MoveTo(m_left+(i-m_Low)*m_IntervalPan/m_Interval , m_bottom);
pDC->LineTo(m_left+(i-m_Low)*m_IntervalPan/m_Interval , m_bottom+6); //x轴的向下的长刻度
}
else
{
// 10的倍数
pDC->MoveTo(m_left+(i-m_Low) *m_IntervalPan/m_Interval, m_bottom);
pDC->LineTo(m_left+(i-m_Low) *m_IntervalPan/m_Interval , m_bottom+2); //x轴的向下的短刻度
}
}
.........
Hansen
|
|
|
|
|
Im not sure is this[^] helpful for you?
|
|
|
|
|
Thank you, I think it is no use . but I still want to say you :Thank you very much to help me .
Hansen
|
|
|
|
|
Im not sure did you need to GetPixel and SetPixel
|
|
|
|
|
Hi, I'm trying to completely suppress a window of another process, i.e. the main window doesn't display, doesn't appear at taskbar for even one second.
Imagine you are playing 3D game in full screen, suddenly a window appears and minimizes your game screen, and you die in the game...
I've tried using SetWindowsHookEx to install a hook for each WH_CALLWNDPROC and WH_CBT, then SetWindowLong to subclass the target window to modify every single call to WM_SHOWWINDOW, WM_SETFOCUS, WM_ACTIVATE, WM_ACTIVATEAPP, WM_WINDOWPOSCHANGING, etc. In addition, I also call LockSetForegroundWindow(LSFW_LOCK) and PostMessage(hWnd, WM_CLOSE, 0, 0) whenever possible.
In the subclass WindowProc, for every WM_WINDOWPOSCHANGING message, I modify the lParam, change the flags to SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_ NOOWNERZORDER|SWP_NOREPOSITION|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_NOZORDER
For every WM_SHOWWINDOW and WM_ACTIVATEAPP message, I modify the wParam to FALSE.
So far, the window will appear for a brief split second then disappear. This is still not good enough for me because of that split second, it minimizes the active game screen.
Does anybody know what other message, or flag that I show be trying? Is what I'm trying to do possible at all?
Thanks much!
|
|
|
|
|
Seriously? You have no control over the app that pops up this window???
|
|
|
|
|
Hi!
what is the problem for calling the CreateHardlink function?
i call this function in my project but it has "undeclared identifier" error.
i define _WIN32_WINNT in .h and .cpp files, but it has this error, yet.
#define _WIN32_WINNT 0X0500<br />
what do i do?
Zo.Naderi-Iran
|
|
|
|
|
I using CreateHardlink with #define _WIN32_WINNT 0X0500 and its compling without problem?where you declare #define
|
|
|
|
|
"#define _WIN32_WINNT 0X0500" is above ".cpp" file, what i call this function into it.
Zo.Naderi-Iran
|
|
|
|
|