|
Thanks PJ and others,
The solution suggested by PJ works if I run the program only once. What about if I want to run the program a number of times with different arguements, as I mentioned in my orginal mail.
I don't want to use bat file. What I need is a alternative way to bat file but through VC++ IDE. Is there any way to write bat file through VC++ IDE?
thanks again
regards
/rsasalm
|
|
|
|
|
A few months ago someone had a tricky resolution to enabling a button only if the CEdit had text in it. It was really elegant and succint, but I cant find it by doing a search of CP messages. Anyways, I cant test this out at the moment but wil this work?
void CAddKeyword::OnChangeEditaddnewkeyword()
{
CString tempNKW;
m_editAddNewKeyword.GetWindowText(tempNKW);
if(tempNKW != "")
m_editAddNewKeyword.EnableWindow(TRUE);
}
In onInitDialog I had done:
m_editAddNewKeyword.EnableWindow(FALSE);
Thanks,
ns
|
|
|
|
|
it will work!
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
If you also want the button to disable again when the edit gets empty (if the user for instance deletes what she previously entered) you've got to be slithgtly change your code:
void CAddKeyword::OnChangeEditaddnewkeyword()
{
CString tempNKW;
m_editAddNewKeyword.GetWindowText(tempNKW);
m_editAddNewKeyword.EnableWindow(tempNKW.IsEmpty()?FALSE:TRUE);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That was me!
And the solution was:
void CAddKeyword::OnChangeEditaddnewkeyword()
{
CString tempNKW;
m_editAddNewKeyword.GetWindowText(tempNKW);
m_editAddNewKeyword.EnableWindow(tempKNW.GetLength() > 0);
}
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Thanks so much! That was it!
|
|
|
|
|
I am checking a CString array to see if a word entered by the user exists in the array already. If it does, I want them to have a choice of entering a new word, or cancelling out. So far I have
CString newKW;
m_editAddNewKeyword.GetWindowText(newKW);
for( int i = 0; i<numFields, i++)
{
if( m_AddKWFldsHolder[i] == newKW)
{
int nRetMB = AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
m_editAddNewKeyword.SetWindowText("");
m_editAddNewKeyword.SetFocus();
but I am aware that this wont do because we want to restart the comparison all over, not from where it left off. I was playing with the MB_YESNO but that was even murkier for me. I'd appreciate any insights or suggestions,
Thanks,
ns
|
|
|
|
|
Code break, repost!
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
void CAddKeyword::OnSubmitkeyword()
{
m_editAddNewKeyword.GetWindowText(m_newKW);
if(m_newKW == "")m_editAddNewKeyword.SetFocus();
for( int i = 0; i (less than) numFields, i++)
{
if( m_AddKWFldsHolder[i] == m_newKW)
{
int nRetMB = AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
m_editAddNewKeyword.SetWindowText("");
m_editAddNewKeyword.SetFocus();
i = 0;
}
}
it didnt like the less than symbol here on CP
|
|
|
|
|
it didnt like the less than symbol here on CP
Replace your < characters with <
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I would recommend using a CMap - the searching will be faster. MFC has not a set class like STL, so you need to use something small like a bool as data:
CMap< CString, LPCSTR, bool, bool > map;
CString newKW = ...
bool dummy;
if(map.Lookup(newKW,dummy))
{
}
else
{
map.SetAt(newKW,dummy);
}
Pavel
Sonork 100.15206
|
|
|
|
|
MFC has not a set class like STL, so you need to use something small like a bool as data
Better yet, use STL's std::set and enter the wondrous STLland!
std::set<CString> s;
CString newKW = ...
if(s.find(newKW)!=s.end()){
}
else{
s.insert(newKW);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
StartSearch:
for( int i = 0; i)
{
if( m_AddKWFldsHolder[i] == newKW)
{
int nRetMB = AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
m_editAddNewKeyword.SetWindowText(""); m_editAddNewKeyword.SetFocus();
goto StartSearch;
Or for those who fear the goto.
BOOL bSearching = TRUE;
while (bSearching)
for( int i = 0; i)
{
if( m_AddKWFldsHolder[i] == newKW)
{
int nRetMB = AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
m_editAddNewKeyword.SetWindowText("");
m_editAddNewKeyword.SetFocus();
bSearching=TRUE;
break;
}
}
bSearching = FALSE;
}
|
|
|
|
|
Ok, simple question. I have a worker thread that I want to change the cursor to an hourglass when it starts, and then back when it's done. I've tried the seemingly innocous:
SetCursor(LoadCursor(NULL, IDC_WAIT));
but alas, no cursor change! The NULL is in place of an HINSTANCE
As with most seemingly simple things, I missed the mark! Any help is always a pleasure
thx!
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
put AfxGetInstanceHandle() to get a HINSTANCE
WUSIWUG
|
|
|
|
|
Ok. Now I have:
SetCursor(LoadCursor(AfxGetInstanceHandle(),IDC_WAIT));
I also tried:
SetCursor(LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_WAIT)));
And yet no cursor change
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
to really change the cursor you should handle the OnSetCursor function (WM_SETCURSOR, i think).
BOOL CISSimpleViewerDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (pWnd==(CWnd *)this)
{
if (nHitTest==HTCLIENT)
{
if ((message==WM_MOUSEMOVE) || (message==WM_LBUTTONDOWN) || (message==WM_LBUTTONUP))
{
SetCursor(AfxGetApp()->LoadCursor(IDC_OPENHAND));
return TRUE;
}
}
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
SetCursor() is not persistent, the new cursor only lasts until the next time your window gets a WM_SETCURSOR message, which is sent every time the mouse moves in your window. If you don't handle that message, DefWindowProc() resets the cursor to the arrow.
Since you're using MFC, just use CWaitCursor .
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Is there anyway that I could print pdf file without using Adobe Acrobat???
|
|
|
|
|
php has some libs for doin this i think but im not sure if they work ok or whatnot
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" what i do who i am
|
|
|
|
|
There are several companies that make PDF libraries that you can use. The only one I have experience with is Zeon (http://www.zeon.com.tw). It does a pretty good job printing, although they render everything as GDI, so Postscript printers don't work as well as they should. They also have a great library for building PDFs that is very similar to Adobe's now-discontinued PDFLib.
I understand there are several open source projects to build similar things, but I haven't spent much time evaluating them.
|
|
|
|
|
Hi,
I have a class derived from CStatic. When cursor is over the control i want the text to change color. To manage this i had override OnPaint. It works fine but the problem is i also want this control to be capable of displaying icons.
I tried the following code but it didn't work:
if( m_hIcon )
{
CStatic::SetIcon( m_hIcon ); (Line 1)
}
else
{
// If no icon is specified just draw the text
dc.DrawText( str, str.GetLength(), rect,
DT_CENTER | DT_VCENTER | DT_SINGLELINE );
}
m_hIcon, is spcified by user by the overriden SetIcon method:
HICON CTableTextStatic::SetIcon(HICON hIcon)
{
m_hIcon = hIcon;
return m_hIcon;
}
Can you tell me what am i doing wrong here?
I also tried replacing "Line 1" above with the below:
dc.DrawIcon( rect.Width() / 2, 0, m_hIcon );
It works but i want the icon to be centered and i couldn't find a way to get icon's size.
And with this way, it draws the icon even if SS_ICON style is not specified. Does that mean using DrawIcon is not a nice way to do it?
Sorry for the long post. It would be great if you could help me on this one.
Thank you in advance.
|
|
|
|
|
I cannot try it right now, but maybe modyfing the style of the control will work:
if(m_hIcon){
ModifyStyle(0,SS_ICON);
}
else{
ModifyStyle(SS_ICON,0);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for replying and sorry for not mentioning the line i created the control:
<br />
CTableTextStatic *pSta = new CTableTextStatic;<br />
pSta->Create( "Test", WS_CHILD | WS_VISIBLE | WS_THICKFRAME | SS_ICON | SS_CENTERIMAGE | SS_NOTIFY, CRect( 525, 100, 650, 125 ), this, 12654 ); <br />
pSta->SetIcon( AfxGetApp()->LoadIcon( IDR_MAINFRAME ) );<br />
So I already declared its style to display icons.
For drawing the icon, there are some nice methods of CDC class such as StrechBlt but instead of HICON i am allowed to use HBITMAP.
|
|
|
|