|
Hi,
I hv made an application using win32, heavy graphics r involved in my project...im facing difficulty displaying the dialog box n msg box..since it is not getin displayed on the leftmouse event at the first time..i-e i want that when i click the leftmouse button at some specific event a dialogbox shud appear...but when i click the mouse button dialogbox aint getin appeared as it goes at the back of my application..may b coz os aint givin it the control, n i hv to go to taskmanager n enable the dialogbox....so if some1 can find a cure for for this ill b extremely thankful....or tel me an alterante to get the user input..
Thnx
|
|
|
|
|
Can you show code ?
ooolz wrote: ...but when i click the mouse button dialogbox aint getin appeared as it goes at the back of my application
Does SetWindowPos help ?
|
|
|
|
|
the code is too large to b attached
|
|
|
|
|
What about my second question ?
You can atleast show how you are invoking dialog box.
|
|
|
|
|
I'm sorry about my mistake 2days ago... cause that is the first time I race on this site. At firts, thanks for replying to my topic.
And now, I introduce about what I've done...
#include
#include
class cspell{
char* mean;// word's meaning
char* warray[12];//warray which is an array include words
public:
void init();//initializing
void check(char*);// check spell
void set(char* m);//add a word to dictionary database
};
I have built this class. And I have met some errors while I setup 3 behaviours(init , check, set).
I want to initialize warray's member... but I can't.
And this...
void check(char* word){
for( int i = 0; i if (strcmp(warray[i], word)==0) {
cout << word;
cout << "Good word.\n";
}
};
And I want to build word's meaning... But I don't know the method...
Do you know about my idea?...
I want to compare a word and a member of warray. But an error appeared.
"Set" behaviour is so hard... Please help me to built this class and its behaviours... Thanks for reading and replying.
My mind is too bad... I have learn this language 2 months ago by myself.
Try to find how to die
|
|
|
|
|
I'm not sure you asked about dictionary but I think we have article about dictionary on codeproject and also use of Ingnore html when want to send a code
|
|
|
|
|
It seems that <valarray> is incompatible with the MFC,
by searching the google I found it may work to #undefine
min(), max(). Is there any alternative to solve this problem?
Thanks!
|
|
|
|
|
ytod wrote: '06
It seems that <valarray> is incompatible with the MFC
What do you mean by incompatible ? Do you get any errors ?
ytod wrote: Is there any alternative to solve this problem?
If you are getting compilation errors, make include statement for valarray as first statement in stdafx.h .
|
|
|
|
|
I'm finding templates a bit hard to understand. I do understand some simple ones, but not everything. I looked at a sample program that finds max of two numbers and returns the bigger number. People say templates are generic but why not it take std::string into the function that finds of Max of two types(now it takes only numbers) We know that it's not sane to try "<" between strings but how does the compiler find the passed values are strings and reject it? and btw, how an STL container gets in anything we push? may it be numbers or strings, for example a vector. Can someone make a simple template program that just "holds" Object of any type, I just want to break the template barrier.
<br />
Box <int> box_int; box_int.hold(1);<br />
Box <std::string> box_str; box_str.hold("Astricks");<br />
Box <myClass> box_obj; box_obj.hold(myObj);<br />
Any help? Plz note: It's not a homework or assignement.
|
|
|
|
|
std::max() works just fine with std::string , and operator < has a well-defined meaning for strings.
|
|
|
|
|
(1) Maybe you are expecting to much from templates. They are just a blueprint for the compiler, how to make functions or classes using the same code for different types.
(2) It *is* sane to use "<" to compare std::string - it overloads operator <
What you mean is probably that < doesn't do a string comparison for char * - and in this case, you are right: the "normal" min() template won't work
template <typename T> T const & min(T const & a, T const & b) { return (a<b) ? a : b; }
This template works for all types that implement a "sensible" operator < . It is generic for all typesthat fulfil this template parameter restriction
In C++ you can even provide a specific implementaiton of a template function for a specific type. This is called template specialization:
<br />
template<><br />
char const * min(char const * a, char const * b)<br />
{<br />
return strcmp(a,b) < 0;<br />
}<br />
(Note: this isn't a recommended solution for the problem at hand, but an illustration of template specialization)
The template saves you from writing the same min function for dozens (or thousads) of types. It does not save you from defining what "min" actually means in terms of C++
(3) Generally, writing correct templates is hard, because you have to be very precise about your template argument restrictions, and you have to keep "all" types in mind.
Used correctly, templates avoid a lot of repetetive code, and are fairly simple to use.
(4) What you ask is simple, but probably not what you want:
template <typename T>
class Box
{
T m_value;
public:
Box(T const & value) : m_value(value) {}
T const & get_value() const { retrun m_value; }
}
However, you haven't broken any "template barrier": Box<string> is a completely different type from Box<int> there is no Box type that can hold both (Box is just a template for types, not a type by itself)
What you want isn't simple. boost::any[^] implements a container type that can hold all kinds of types.
(5) Try to read more[^] on templates, try to understand the common ground that these tutorials cover.
Good luck!
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|
|
Thank you so much perterchen, Now I will sit on work on your explanation . Thanks a lot
|
|
|
|
|
Your example was so nice, realy useful. thanks a lot man. And I tried another simple thing, but why do I get this error peter?
template<class T> class Key
{
T k;
T* kptr;
int length;
public:
Key(T);
};
void main()
{
Key < int > i;
}
: error C2512: 'Key<int>' : no appropriate default constructor available
*
|
|
|
|
|
If a coworker asked me that, I'd start with a "questions" game: What does the compiler say? Where does it saay that? etc. - you could work this out yourself
since you declare Key(T), the default constructor Key() is not generated automatically.
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|
|
oops, just a simple mistake. I'm taking up templates with an assumption it's too difficult to understand. So any error it throws look big for me . Sorry peter, it's the usual "no definition" error. Damn, I should have put Key(T){}. Now I defined it inline. Sorry for the stupid question. And Btw, next time if I come up with a good question would you try to extend your support? please?
*
|
|
|
|
|
No problem I just want to encourage you to help yourself.
Astricks wrote: And Btw, next time if I come up with a good question would you try to extend your support? please?
No promise, but you aren't on a black list or something
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|
|
peterchen wrote: No problem I just want to encourage you to help yourself.
Thanks peter .
peterchen wrote: you aren't on a black list or something
pheww!
*
|
|
|
|
|
Environment:
Windows XP Professional 32-bit
Visual Studio C++ Express Edition 8.0 SP2
Platform SDK Windows 2003 Server RC2
Project: C++, Windows 32-bit (x86), Debug, Unicode
<br />
Compiling...<br />
Dialog.cpp<br />
d:\lbm\bdm\dialog.cpp(43) : warning C4244: 'argument' : conversion from 'LONG' to 'LONG', possible loss of data<br />
[rest of compilation continues]<br />
The code triggering the warning message:
#ifdef _WIN64
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG_PTR)(wcDlgInfo->m_wcDlgProc));
#else
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG __w64)(wcDlgInfo->m_wcDlgProc));
#endif
Normally the line
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG_PTR)(wcDlgInfo->m_wcDlgProc));
would suffice, but this also complains about the conversion of LONG_PTR to LONG, as if LONG_PTR is 64-bit:
Compiling...
Dialog.cpp
d:\lbm\bdm\dialog.cpp(47) : warning C4244: 'argument' : conversion from 'LONG_PTR' to 'LONG', possible loss of data
Any ideas why
- LONG_PTR is considered "larger" than LONG on 32-bit x86, and
- what means exactly the "conversion from LONG to LONG" warning message means, since _WIN64 is not defined?
Many thanks,
Cristian Amarie
|
|
|
|
|
I'm not sure about the error message, but...
Cristian Amarie wrote: but this also complains about the conversion of LONG_PTR to LONG, as if LONG_PTR is 64-bit
A LONG_PTR IS a 64-bit value in a 64-bit build. That's the whole reason for the newer type. It's
a LONG but large enough to hold a pointer when pointers are 32-bit or 64-bit.
I'm not sure what a "LONG __w64" is, but this line...
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG __w64)(wcDlgInfo->m_wcDlgProc));
...won't work on a 32-bit build because pointers are 32-bit therefore you need to pass a 32-bit
value. Sure, you can cast a 64-bit but it's going to be truncated to 32-bits.
Mark
|
|
|
|
|
[A LONG_PTR IS a 64-bit value in a 64-bit build]
True, but as I stated in environment, is a 32-bit build.
[I'm not sure what a "LONG __w64" is, but this line...]
(Microsoft Specific) Lets you mark variables, such that when you compile with /Wp64 the compiler will report any warnings that would be reported if you were compiling with a 64-bit compiler.
Is a "marker".
About the last part of message, true, but (LONG __w64) was on #else part of #ifdef _WIN64.
|
|
|
|
|
Hmm
What type is wcDlgInfo->m_wcDlgProc?
|
|
|
|
|
typedef LRESULT (CALLBACK *WCDLGPROC)(HWND, UINT, WPARAM, LPARAM);
m_wcDlgProc is a pointer (to a window procedure).
|
|
|
|
|
Yeah that's a good WTF
This...
::SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG)(LONG_PTR)(wcDlgInfo->m_wcDlgProc));
..."fixes" it on VS2003.
I'd call that a bug, but every time I do, someone has a good reason for the behavior
|
|
|
|
|
Now that's a stretch (Dad to DeeDee - Dexter's Laboratory)
|
|
|
|
|
Cristian Amarie wrote: Normally the line
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG_PTR)(wcDlgInfo->m_wcDlgProc));
would suffice, but this also complains about the conversion of LONG_PTR to LONG, as if LONG_PTR is 64-bit:
I aggree with you. This should suffice. About warning, probably this could be issue with IDE.
|
|
|
|
|