|
So what you're saying is write a batch file that will take in the date and then call the original batch file to run? That makes sense but why can the original batch file be called from the prog? Also this is something I am wanting to be automated and run every day. So I can't just have a static date.
|
|
|
|
|
Camron wrote:
So what you're saying is write a batch file that will take in the date and then call the original batch file to run?
No. The batch file you create at runtime will contain those commands that you would otherwise issue at a command prompt.
Camron wrote:
That makes sense but why can the original batch file be called from the prog?
I assume you mean why can't it be called from the program. It can with a fair amount of finagling. I find it much easier to do it this way.
Camron wrote:
Also this is something I am wanting to be automated and run every day. So I can't just have a static date.
No need to. You create the .bat file each time you need it, specifying a different date each time. When you are all done, simply remove the .bat file.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I'm not sure why you need to use CreateProcess. And why not programmatically create the batch file each time? For example,
#include <fstream.h><br />
<br />
fstream batchFile;<br />
batchFile.open("Launch.bat", ios::out);<br />
if(!batchFile){ }<br />
<br />
batchFile << "U:" << endl;<br />
batchFile << "cd \\telmage" << endl;<br />
strftime(GTime, sizeof(GTime), "%m %d %y", localtime(&yesterday));<br />
batchFile << "telmage " << GTime << endl;<br />
<br />
batchFile.close();<br />
<br />
if(WinExec("Launch.bat", 0) < 32){<br />
}<br />
<br />
This code works like DavidCrow suggests, with a batch file calling the original batch file, only you won't have to recreate the calling batch file every day by hand.
Hope this helps!
Danny
-- modified at 13:16 Tuesday 20th September, 2005
|
|
|
|
|
I'm not sure the last two params of CreateProcess can be NULL - my SDK documentation certainly doesn't say that they can be. Maybe this is your problem?
|
|
|
|
|
The process and startup info structures cannot be NULL.
--
The Blog: Bits and Pieces
|
|
|
|
|
A test shows that a CListCtrl which is not report style won't send WM_DRAWITEM or WM_MESUREITEM to its parent, though it has the LVS_OWNERDRAWFIXED style. I am not sure whether it is the case.
|
|
|
|
|
It is as you said. Only in report mode the list-view control does support owner-drawing.
Have a look at the SDK:
<br />
LVS_OWNERDRAWFIXED <br />
The owner window can paint items in report view. The list-view control sends a WM_DRAWITEM message to paint each item; it does not send separate messages for each subitem. The iItemData member of the DRAWITEMSTRUCT structure contains the item data for the specified list-view item. <br />
Don't try it, just do it!
|
|
|
|
|
Hi
I am showing a bitmap in my dialog based MFC programm.
I have also put some Static Control and that goes overlapped to the bitmap I want to saw.
Is there any way to show bitmap at forground and static control in background so that we can see the bitmap still overlapping the static control
My code is as follow :
MyDlg.cpp
=========
BOOL MyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
OnInitBitmap();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
return TRUE;
}
void CMyDlg::OnInitBitmap()
{
//Give the path and name of bitmap file to the given Bitmap variable
m_sBitmap = "C:\\Test.bmp";
HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), m_sBitmap, IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if(hBitmap)
{
if (m_bmpBitmap.DeleteObject())
m_bmpBitmap.Detach();
m_bmpBitmap.Attach(hBitmap);
}
return;
}
void MyDlg::ShowBitmap(CPaintDC *pdc)
{
BITMAP bm;
int iStartX,iStartY, iHeight, iWidth;
HWND hWnd;
bool bRes;
CRect myRect;
hWnd = ::GetDesktopWindow();
bRes = ::GetWindowRect(hWnd,myRect);
ClientToScreen(myRect);
m_bmpBitmap.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(pdc);
CBitmap *pOldBitmap = (CBitmap *) dcMem.SelectObject(m_bmpBitmap);
CRect lRect;
GetClientRect(lRect);
lRect.NormalizeRect();
iStartX = m_BorderWidth;
iStartY = myRect.Height();
iHeight = bm.bmHeight-20;
pdc->StretchBlt(iStartX,iStartY,iWidth, iHeight, &dcMem, 0,0, bm.bmWidth,bm.bmHeight, SRCCOPY);
return;
}
void MyDlg::OnPaint()
{
CPaintDC dc(this);
ShowBitmap(&dc);
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
CDialog::OnPaint();
}
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
is there anything like zindex in MFC? i'm not sure..
Regards,
V
|
|
|
|
|
Vivekuniq wrote:
like zindex in MFC
Zindex or Z-order is way application windows are placed in Windows Enviornment
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
void MyDlg::OnPaint()
{
CPaintDC dc(this);
ShowBitmap(&dc);
}
this is the only paint you need to do...
NG
|
|
|
|
|
I have a set of activeX controls. These controls are invisible at runtime. i have to create a project that use them like the follow way.
The methods defined in the activeX controls will be utilized by some aplication. They(ActiveX controls) will call methods in a dll. This dll makes interface with some devices, like printers.
I'm not knowing how to create the correct projects in The Visual C++ and how to link ocx and dll.
P.S.: If helps, all this is about OPOS DRIVER!
I wait for reply!
Greatiful!
Hélio
|
|
|
|
|
Hello guys,
In my dialog based MFC application I have two Static Control in which I saw text.
There is no menu and nothing else on that dialog box.
Now I want to put some code so that I can terminate the application by pressing any key or key combination with Alt or Ctrl key or some Function key.
For that I have tried WM_KeyDown and OnKeyDown and OnChar() functions but as focus is on Static control I m not able to capture that KeyDown event.
Some one suggested me to use Accelarator but that also I am not sure will work or not ? If yes then is there any simple example how to attache accelarator to my dialog(or static control )?
Thank you very much
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
I'm not sure of the exact name, but it's **_NOTIFY. you have to add this to your style for your static control either in the resource.h file, or in the create() statement (if you create it dynamically). Static controls won't process any clicks, keypresses, or anything until you add this to the style argument.
My articles
BlackDice
|
|
|
|
|
void CYourStatic::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
CWnd::PreSubclassWindow();
ModifyStyle(0, SS_NOTIFY);
}
NG
|
|
|
|
|
Hi
I have a dialog based MFC application. In this I want to color my dialog, but I don't want to color whole dialog, instead i want to leave a some pixels of border on all four side of dialog.
I am able to color my dialog by putting this code into my MyDlg.cpp file
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
hbr = CreateSolidBrush(RGB(255,0,0));
return hbr;
}
How can I leave the border around my dialog ?
Any help..
Thankx in advance..
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
here you have a memory leak
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
hbr = CreateSolidBrush(RGB(255,0,0));
return hbr;
creating a brush every time that a control of dialog, request it
do on OnPaint()
{
CPaintDC dc(this);
CRect rc;
GetClientRect( &rc );
rc.DeflateRect(10,10,10,10);
dc.FillSolidRect( &rc, RGB(0,0,0));
}
NG
|
|
|
|
|
Simple. Just looking for a good site that goes over all the basics of MFC, possibly with some good tutorials. Any help?
Danny
|
|
|
|
|
|
CodeProject is awesome. I'd say the best part about this site is the forum for programmers to answer other programmer's questions. The articles are great, too, but at times too specialized for what I'm looking for. I mean, beyond the basic listing of member functions that MSDN gives me, a site that really teaches all the basics of MFC. I have some great sources here in the office, but I don't like to bug them for help when I'm trying to learn a new control or feature. (new = I haven't used it yet)
Danny
|
|
|
|
|
where were u toxxct? i haven't seen u for couple of days or so.. or u OK?
V
|
|
|
|
|
yes yes, i'm there, every day, but as there are not always good posts, and as i have to work hard...
but if you search a bit more (my posts are here[^]), you'll see that i am still active...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
ohh.. ok .. i felt i missed the bright organge colored text on few pages..
V
|
|
|
|
|
It would be nice to be able to find aritcles by beginner/tutorial classification.
The tigress is here
|
|
|
|
|