|
Hi all,
Is it possible to retrieve previously selected index when an ON_LBN_SELCHANGE is fired from a CListBox control? It appears to me that I need to store such information manually.
Thank you!
|
|
|
|
|
An application sends the LBN_SELCHANGE notification message when the selection in a list box is about to change...
So the selection has not yet changed in the moment you receive that notification. CListBox::GetCurSel should return the previously selected item.
Don't try it, just do it!
|
|
|
|
|
Hmm...it appears to me that CListBox::GetCurSel returns the newly selected item not the previous one? What did I miss?
Thanks for the reply
|
|
|
|
|
Can I display SlidderBar in the semi-circle shape,as it looks in the straight line by default.
Its my project requirement,if possible please answer my question and post it as early as possible.
P.S.Kiranmaye
|
|
|
|
|
P.Sunitha Kiranmaye wrote:
Can I display SlidderBar in the semi-circle shape,as it looks in the straight line by default.
Not by default. You'll need to draw this one yourself.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
As David said, you have to draw it yourself. Look here[^] for some examples of custom drawn slider controls.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I'm trying to write a program that will initiate a batch file. For some reason the program keeps crashing. I'm not too familiar with the createprocess function so I figure I'm doing something wrong with that. To run the program in a DOS prompt I must be in the path U://telmage/ To run the process I type telmage 09 19 05 or the previous days date. Does anyone have any idea what I might be doing wrong?
[CODE]
void main()
{
char path_buffer[_MAX_PATH];
char GTime[80];
time_t now;
UINT value;
now = time(NULL);
time_t yesterday = now - 86400;
strftime(GTime,sizeof GTime,"telmage %m %d %y",localtime(&yesterday));
_makepath( path_buffer, "U", "\\telmage", GTime, "" );
cout<
|
|
|
|
|
I would create a .bat file with the following commands in it:
U:
cd \telmage
telmage 09 19 05
and then call CreateProcess() specifying the .bat file as the command to run.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
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
|
|
|
|