|
plz can any one help me in deleting a Text file thru c or c++ vc++ program..
( i am using "ShellExecute(NULL, "del","c:\\res.txt",0, 0, SW_HIDE);" but this statment is not working.)
|
|
|
|
|
1.Windows API
BOOL DeleteFile(<br />
LPCTSTR lpFileName
);
2. MFC method
static void PASCAL Remove( LPCTSTR lpszFileName );<br />
throw( CFileException );
3. Windows Shell API
SHFileOperation()
I'd prefer the first way, but the 3rd way is powerful
|
|
|
|
|
I'm trying to draw a stetched image, but only the part that need updating, with the following code:
if (IntersectRect(&rcIntersected, &ps.rcPaint, &rcImgScrolled))
{
float rx = (float)ImgWidth / (float)ZoomedImgWidth;
float ry = (float)ImgHeight / (float)ZoomedImgHeight;
int dl = rcIntersected.left - ps.rcPaint.left;
int dt = rcIntersected.top - ps.rcPaint.top;
int dw = RECTWIDTH(rcIntersected);
int dh = RECTHEIGHT(rcIntersected);
int sl = int(float(rcIntersected.left - rcImgScrolled.left)*rx);
int st = int(float(rcIntersected.top - rcImgScrolled.top)*ry);
int sw = int(float(RECTWIDTH(rcIntersected))*rx);
int sh = int(float(RECTHEIGHT(rcIntersected))*ry);
StretchBlt(hDCBuffer,
dl, dt, dw, dh,
hDCCurImg,
sl, st, sw, sh,
SRCCOPY);
}
The problem is when the window is at certain sizes (the zoom is scaled to the window), the last row or column isn't drawn.
I know it's because of the floats being rounded off, but how do you fix so it gets the exact number of pixels needed?
I tried floor() which had no effect, and ceil() which would sometimes draw an extra row or column of random colors...
-thanks
|
|
|
|
|
did someone have this problem the other day?
my app hangs quite often when i try to debug
any suggestions?
|
|
|
|
|
hi,
i want to know any method i can use Visual Studio .NET to build application with old mfc class. so that i dont need to ship the mfc71.dll?
actually, i can build my convert and build old application in visual studio .net. however, it link to mfc71.dll. i dont want this. any help?
Thanks!
jim
|
|
|
|
|
Nope, I very much doubt there is any chance you can do this. You can install VC6 next to VC7 though.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
zecodela wrote:
want to know any method i can use Visual Studio .NET to build application with old mfc class. so that i dont need to ship the mfc71.dll?
actually,
If you use static linking to MFC rather than dynamic linking, then you won't need to ship with any MFC dlls.
Michael
CP Blog [^]
|
|
|
|
|
Hey, got another question.
I hace a combo box and an edit box, and in the combo box, there is options for time, 10 mins, 20 mins etc etc. And when you click on them, it adds it to the edit box and keesp track of the total, remeber there are 7, so you choose 7 values and it adds it up, but if you hit the wrong value and change to the other one it adds both values to the edit box, and you can't change it back without restarting the program.
<br />
int cur = m_type2.GetCurSel ();<br />
CString text;<br />
m_type2.GetLBText (cur, text);<br />
<br />
<br />
int cur1 = m_dur2.GetCurSel ();<br />
CString text1;<br />
m_dur2.GetLBText (cur1, text1);<br />
if (text1 == "10 Minutes")<br />
{<br />
if (text == "Swimming #1" )<br />
{<br />
totalswim+=10;<br />
totalrun+=0;<br />
totalcycling+=0;<br />
totalstrength+=0;<br />
}<br />
else<br />
if (text == "Run #1" )<br />
{<br />
totalrun+=10;<br />
totalswim+=0;<br />
totalcycling+=0;<br />
totalstrength+=0;<br />
}<br />
else<br />
if (text == "Cycling #1" )<br />
{<br />
totalcycling+=10;<br />
totalrun+=0;<br />
totalswim+=0;<br />
totalstrength+=0;<br />
}<br />
else<br />
if (text == "Strength #1" )<br />
{<br />
totalcycling+=0;<br />
totalrun+=0;<br />
totalswim+=0;<br />
totalstrength+=10;<br />
}<br />
else<br />
if (text == "Stretching #1" )<br />
{<br />
totalswim+=0;<br />
totalrun+=0;<br />
totalcycling+=0;<br />
totalstrength+=0;<br />
}<br />
Hours(); <br />
}<br />
<br />
<br />
void CDEPDlg::Hours()<br />
{<br />
<br />
<br />
<br />
CString str;<br />
str.Format(TEXT("%i"),totalswim);<br />
m_swimtime.SetWindowText (str);<br />
<br />
CString str1;<br />
str1.Format(TEXT("%i"),totalrun);<br />
m_runtime.SetWindowText (str1);<br />
<br />
CString str2;<br />
str2.Format(TEXT("%i"),totalcycling);<br />
m_cyclingtime.SetWindowText (str2);<br />
<br />
CString str3;<br />
str3.Format(TEXT("%i"),totalstrength);<br />
m_strengthtime.SetWindowText (str3);<br />
<br />
}<br />
That is the code for it, if you have any ideas of how to have it to waht I need it to do, please post, becasue I am out of ideas and don't really know how else to do it.
Thanks
|
|
|
|
|
You can provide another button to undo the last operation
or a "Reset" button to start again. At least it is better
than re-starting
Due Regards
Mahendra
|
|
|
|
|
Hi,
As a side issue have you considered using SetItemData to make the code look cleaner?
e.g. create enum for the Activity:
enum enumActivity
{
eSwim = 0,
eRun,
eCycle,
eStretch
};
Then when you create both combos...
CString strText;
for(int t=10; t<=60; t++)
{
strText.Format("%d Minutes");
int nIdx = m_dur2.AddString(strText);
if (nIdx >= 0) m_sur2.SetItemData(nIdx, t);
}
int nIdx2 = m_type2.AddString(_T("Swimming"));
if (nIdx2 >= 0) m_type2.SetItemData(nIdx2, (DWORD)eSwim);
nIdx2 = m_type2.AddString(_T("Running"));
if (nIdx2 >= 0) m_type2.SetItemData(nIdx2, (DWORD)eRun);
Then in the handler you gave the code for you can use a nice switch statement:
int cur1 = m_dur2.GetCurSel ();
int cur = m_type2.GetCurSel ();
switch((enumActivity)m_type2.GetItemData(cur))
{
case eSwim:
totalswim += m_dur2.GetItemData(cur1);
break;
case eRun:
totalrun += m_dur2.GetItemData(cur1);
break;
}
Hope this helps,
Andy
|
|
|
|
|
Hi guys,
I need to show my dialog always at maximised. So I use ShowWindow(SW_SHOWMAXIMIZED) . The problem is that the window that is shown will be full screen and covers the taskbar, if MAXIMIZE BOX is disabled (Resource View -> uncheck MAXIMIZE BOX)
Is there any way to show a maximised dialog with the taskbar still available when MAXIMIZE BOX is not included?
Thanks
|
|
|
|
|
<br />
OnInitDialog(){<br />
.......<br />
CRect rc;<br />
CWnd* pWnd=GetDesktopWindow();<br />
pWnd->GetWindowRect(rc);<br />
MoveWindow(0,0,rc.Width(), rc.Height(), TRUE);<br />
....<br />
}<br />
Is that all your needs?
|
|
|
|
|
Thanks for the reply,
I think you've misunderstood a bit. I want to show a maximised window that does NOT cover the taskbar area. You might want to try it yourself, have a dialog that the MAXIMIZED BOX is selected FALSE or is not ticked in the resource view. And place ShowWindow(SW_SHOWMAXIMIZED) in OnInitDialog . In my system, that creates a maximised dialog window in full screen. Try to restore the MAXIMIZED BOX, the window is then maximised, with the taskbar still showing.
I could somehow force it using
CRect deskRect;
SystemParametersInfo(SPI_GETWORKAREA, NULL, &deskRect, 0);
MoveWindow(&deskRect);
</code>
But this is not so great because the dialog is not in maxmised mode (where window borders are hidden) and also it's been fixed so if taskbar's size is later changed, the dialog window will still stay the same.
|
|
|
|
|
Try it with Border Resizing
|
|
|
|
|
Thanks Dreamz,
OnSizing() handler in my app isn't be able detect resizing of other applications, including the taskbar. I tried anyway, it won't resize.
|
|
|
|
|
Dont know whether i missed something.But i was talking about the Dialog Properties->Border->Resizing
|
|
|
|
|
Thanks Dreamz,
that's in fact the solution for me That was not difficult at all.
Thanks again
|
|
|
|
|
Welcome
Glad to know it helped you.
|
|
|
|
|
VC++.net,excel 2000,
at first I import the lib as below#import "p:\ofc2000\program files\microsoft office\office\mso9.dll" no_namespace rename("DocumentProperties", "DocumentPropertiesXL")
#import "p:\ofc2000\program files\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb" no_namespace
#import "p:\ofc2000\program files\microsoft office\office\excel9.olb" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") rename("DocumentProperties", "DocumentPropertiesXL") no_dual_interfaces
//#import "P:\ofc97\MSAPPS\VBA\vbeext1.olb" no_namespace
#pragma warning (disable:4192)
And the I open an exsiting spread sheet:
CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"Excel.Application", &clsid);
if(FAILED(hr))
{
::MessageBox(NULL, "CLSIDFromProgID() failed", "Error", 0x10010);
return;
}
IDispatch *pXlApp;
hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&pXlApp);
pXL.GetActiveObject(L"Excel.Application");
pXL.CreateInstance(L"Excel.Application");
pXL->Visible = VARIANT_TRUE;
pBook=pXL->Workbooks->Open(_T("H:\\xxs\\c++\\geopro\\Print2excel\\P2E\\Geofoam_Slope_Program.xls"));
DWORD aa=::GetLastError();
//Get the Second sheet.
pSheets = pBook->GetSheets();
pSheet = pSheets->GetItem(COleVariant(short(2)));
no error in compile and link,,
error occurs in running, I can open the spread sheet,problem comes from getting the second page of the sheets:GetItem(COleVariant(short(2)));
but this code can run in VC6.0 very well,and error comes from VC++.net,
Why??
Thank you, any suggestion is admired?
asfazxdfvzxvcxzcv
|
|
|
|
|
When you say "error comes from VC++.net", do you mean you're just getting an error when executing that last line 'pSheet = pSheets....'?
I'm assuming that you've cut and pasted some of the code, since it's not exactly clear why you're doing GetActiveObject and CreateInstance
By error, can you be more specific? Since you're using wrapper classes, rather than raw interfaces, any failure will be throwing a _com_error& exception. Can you catch this and interrogate it to try and get more error information? That would probably help the diagnosis.
Steve S
Developer for hire
|
|
|
|
|
Hey,
I am trying to get my menu that I created to show up on a dialog box. I can do it on the document based ones, but that was a long time ago, and can't remember how to do it.
Does anyone have any tutorials on how to create a basic menu? I have found some tuts with many advanced features and don't need all that stuff.
Thanks
|
|
|
|
|
Create the menu in Resource Editor. Add it to the dialog window via SetMenu().
Kuphryn
|
|
|
|
|
Could you perhaps eleborate on the SetMenu() function a bit?
|
|
|
|
|
SetMenu() takes a pointer to a CMenu object. That is it. Declare a CMenu object as the dialog window's member.
Kuphryn
|
|
|
|
|
ok, so i create a menu, go to the class wizard and it asks me to make a new class, so lets say i name it DEPMenu, I then go to the init function of the dialog and type
SetMenu(?);
the ? means what exactly goes inside of it?
|
|
|
|
|