|
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.
|
|
|
|
|
I solved my problem. In case, in the future someone faces the same problem i decided to write how i solved it:
Instead of using DrawIcon method of CDC, i used DrawIconEx.
if( m_hIcon )
{
::DrawIconEx( dc.m_hDC,
( rect.Width() / 2 - m_nIconWidth / 2 ),
( rect.Height() / 2 - m_nIconHeight / 2),
m_hIcon,
m_nIconWidth,
m_nIconHeight,
NULL,
NULL,
DI_IMAGE );
}
else
{
if( str )
{
dc.DrawText( str, str.GetLength(), rect, DT_CENTER
| DT_VCENTER | DT_SINGLELINE );
}
}
and SetIcon function
void CTableTextStatic::SetIcon(HICON hIcon, int width, int height)
{
m_hIcon = hIcon;
m_nIconWidth = width;
m_nIconHeight = height;
}
This way, i can specify any size for icon and it resizes( stretches or compresses) the icon automatically. And it draws centered.
|
|
|
|
|
I want to use some of the symbols of the font webdings or wingdings on a button, I can change the font of the button to all the outhers but no to this ones
anyone knows why?
Casa.Sapo.pt
|
|
|
|
|
I've seen somebody doing this:
switch(msg)
{ case WM_INITDIALOG:
{
return TRUE;
}
`:
{ int id=LOWORD(wParam);
if (id==IDOK)
{
}
if (id==IDOK || id==IDCANCEL) EndDialog(hwnd,id);
} break;
}
What I don't understand is the `: . My visual studio can't compile it, unrecognized patati patata...
What does the programmer mean by it?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
You are dreaming. You have never seen anyone do anything like that since it's illegal code.
Maybe you have seen some one do it with "ticks" (') added round the "back-tick" or in a web-page that for some reason f***ed it up, or for a WM_CHAR with ESC (ASCII 27, which obviously can't be displayed)?
But again, you have _never_ seen C or C++ code that worked look like what you displayed.
|
|
|
|
|
|
A typo or some problem with formating the code in HTML editor.
Pavel
Sonork 100.15206
|
|
|
|
|
When i get to a certain point in my code:
acmDriverOpen(&hacm, hadid, 0);
I get a "User breakpoint called from code at 0x000XXXX" message and in the Output windows it says:
HEAP[MP3.exe]: Invalid Address specified to RtlFreeHeap( 01560000, 01564260 )
Unhandled exception at 0x77f767cd in MP3.exe: User breakpoint.
I would really appreciate it if someone told me what this means and possibly how i can fix it.
Thankyou
-Rune
|
|
|
|