|
vijay7173 wrote: i am trying to provide auto scroll feature to a CListCtrl box.that is, when the listctrl is filled with more items, the control should automatically scroll such that the last added items is visible.
Take a look at CListCtrl::EnsureVisible .
Owner drawn
Jesus Loves
|
|
|
|
|
|
I have created a custom window in which all the non-client area is redefined. I have custom borders, a custom title bar and custom min/max/close buttons. For the most part everything is working as I want, but I'm having some serious trouble handling button clicks.
I handle the WM_NCHITTEST returning the appropriate code for the new window area. I want DefWindowProc() to handle most of the functionality, but it is really messing things up. When the close button is clicked a WM_NCLBUTTONDOWN message is sent. If I handle this and return 0, a WM_NCLBUTTONUP message is sent (if a button was clicked), but the window is unable to be resized, also the window does not close. If I allow DefWindowProc() to handle the message, the window can be resized but a WM_NCLBUTTONUP message is never sent, again nothing happens when clicking the button.
I have tried using spy++ to monitor messages of other windows behaviour, but I cannot see much difference. From the docs, I read that DefWindowProc() will send the appropriate WM_SYSCOMMAND message, but I can't understand why it is not working within my code.
Does anybody have an idea what I am doing wrong, what I am missing or not handling correctly? Also, is there any way to see the code for DefWindowProc() (possibly a unix/wine variant) to help me understand what is happening behind the scenes.
|
|
|
|
|
Please look up the docs with the following keywords
HTCLOSE, HTMAXBUTTON, HTMINBUTTON....
WM_NCHITTEST should return appropriate values based your non client area design. For example clicking on close button, you should try to find out if the mouse pointer is inside the close button area, if it is then you should return HTCLOSE .
Owner drawn
Jesus Loves
|
|
|
|
|
In the opening thread I did state that I handle the WM_NCHITTEST message and return the appropriate value. This is not the cause of the problem since I am correctly returng a value for the min/max/close buttons aswell as the correct value for the border positions. Also, I should note that from the buttonup/down handlers, I can see that the wparam is correctly initialized with the correct HT... code and that DefWindowProc() is also being called with the correct wParam (the hit test value) and lParam (the mouse position).
The problem is that somewhere DefWindowProc() is doing something and getting an incorrect value. The trouble is I don't know what other message, if any, I should be handling.
|
|
|
|
|
Just an update incase of others with similar problems. I can't be sure, but I have a strong feeling that when DefWindowProc() handles the WM_NCLBUTTONDOWN messages it goes into a GetMessage loop after a call to SetCapture() , within this loop DefWindowProc() calls it's own WM_NCHITTEST handler rather than sending a message to call the users handler. Since it's impossible for DefWindowProc() to know where the new HitTest regions are, it will never work. The only solution is to handle all WM_NCLBUTTONDOWN messages yourself.
|
|
|
|
|
I want to convert "abcd" into ASCII code
but I met a strange problem. My code is below.
<br />
char *s="abcd";<br />
int br[100];<br />
for(int i=0;i<4;i++)<br />
{<br />
br[i]=__toascii(s[i]);<br />
cout << br[i] << "\n";<br />
}<br />
string kkb=""; <br />
kkb=kkb.insert(0,br[1].ToString());<br />
cout << kkb;<br />
and there is an error at kkb=kkb.insert(0,br[1].ToString());
error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::insert(__w64 unsigned int,const std::basic_string<_Elem,_Traits,_Ax> &)' : cant convert argument 2 from 'System::String ^' to 'const std::basic_string<_Elem,_Traits,_Ax> &'a
It's very strange that I change the code
kkb=kkb.insert(0,br[1].ToString());
into
kkb=kkb.insert(0,"a string");
then it works.
I dont understand that both them are string.
why as long as I put the string variable int the function, it has an error?
Can somebody help me?
Thanks a lot.
minihotto
|
|
|
|
|
may be as i guess caz you are using it after the {} so it has error if you use this string inside {} it will work fine
|
|
|
|
|
minihotto wrote: I dont understand that both them are string.
why as long as I put the string variable int the function, it has an error?
better post it in it specific forum Managed C++[^]
"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
Support CRY- Child Relief and You
|
|
|
|
|
Yup.
System::String is a Managed C++ string, while std::string is an STL string. You need a way of getting the contents of the first in a format that the STL string operator(s) can understand. You'd do better asking in the Managed C++ forum, I think.
Steve S
Developer for hire
|
|
|
|
|
I am trying to add this oledb connection string in my program but it gives me erroe ?can anybody tell me what went wrong,do i need to include any thing in header or ....anything else
<br />
OleDbConnection* conn = new OleDbConnection(<br />
<br />
"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\test.mdb");<br />
conn->Open;<br />
<br />
Error:
C2065: 'OleDbConnection' : undeclared identifier
: error C2065: 'conn' : undeclared identifier
: error C2061: syntax error : identifier 'OleDbConnection'
: error C2227: left of '->Open' must point to class/struct/union
|
|
|
|
|
It seems you need to inlcude.
|
|
|
|
|
|
abrakadbra wrote: include what
Header having definition of class OleDbConnection .
|
|
|
|
|
Isn't that a managed class? .NET?
Namespace is System.Data.OleDb
|
|
|
|
|
Hello Everyone,
I'm a newbie, Please help me!
I'm adopting the code that could redirect a console output into the MFC Edit box.
My problem is, i want to have a live redirection from the console output to the edit box because i have a console application that will run about 5-10 mins and produces lots of information (output) in between those time in the command line.
My recent code will just wait the application to finish up before it could redirect the output from the command line to the Edit box.
Please help!.... thank you very much..
-rupert-
i need to learn more... i want to be like you guys... i'm just a begginer
|
|
|
|
|
rupert_durans wrote: My problem is, i want to have a live redirection from the console output to the edit box because i have a console
Does this[^] article by Sudheesh P.S. help you.
Owner drawn
Jesus Loves
|
|
|
|
|
Hello,
I tried to use the idea but it doesn't work, i even tried to download the code and tried to manipulate it, it still doesn't work...
It even hanged when i tried to read from console...
thanks
i need to learn more... i want to be like you guys... i'm just a begginer
|
|
|
|
|
I have a project which loads couple dlls. By Default, it loads from Windows/System32. I was trying to debug the problem with it's crash. And I would like to build a debug version with all the dll files that could run from the same directory as my main executable. However, some dll were loaded from the debug directory only which means if I delete the dlls from the debug directory of my project then it won't run. Even if I put the dlls in the same directory as the main exe or the windows/system32.
What kind of setting in my project could lead the loading of a dll from debug directory?
Or how could I set the dll loading always look for current directory and then windows/system32?
Thanks
ccp
PS...Visual Studio 6.0 VC++
-- modified at 21:58 Monday 16th October, 2006
|
|
|
|
|
Use explicit linking (LoadLibrary) instead of implicit. Giving path of dll you want.
|
|
|
|
|
im trying to create a thread to listen on a port for incomming data but i keep getting errors
HANDLE Handle_Of_listener = 0;
Handle_Of_listener = CreateThread( NULL, 0, listener, &s, 0, NULL);
when i try to compile that it returns:
.\main.cpp(34) : error C3867: 'Messenger::listener': function call missing argument list; use '&Messenger::listener' to create a pointer to member
soo i do what it says and create a pointer to my listener() function
Handle_Of_listener = CreateThread( NULL, 0, &listener, &s, 0, NULL);
errors:
.\main.cpp(34) : error C2276: '&' : illegal operation on bound member function expression
i mean come on i do what it tells me to the says it's illegal!!
|
|
|
|
|
The problem is not in the CreateThread() call.
It's in the declaration of Messenger::listener
How are you declaring that function in your Messenger class?
EDIT: It should be
static DWORD WINAPI listener(LPVOID lpParam);
Mark
|
|
|
|
|
i am now getting this error when i declared it as
static DWORD WINAPI listener(SOCKET s)
.\main.cpp(34) : error C2664: 'CreateThread' : cannot convert parameter 3 from 'DWORD (__clrcall *)(SOCKET)' to 'LPTHREAD_START_ROUTINE'
|
|
|
|
|
You want to pass the SOCKET to the thread procedure correct?
Declare your class-member thread procedure as
static DWORD WINAPI listener(LPVOID lpParam);
Write the function something like this:
DWORD WINAPI myclass::listener(LPVOID lpParam)
{
SOCKET s = (SOCKET)lpParam;
... do stuff with the socket...
return 0;
}
Create the thread something like:
HANDLE Handle_Of_listener_thread = 0;
Handle_Of_listener_thread = CreateThread( NULL, 0, listener, (LPVOID)s, 0, NULL);
Better?
Mark
|
|
|
|
|
thank you!
i shall try this as soon as i get home!
-- modified at 16:06 Thursday 19th October, 2006
still getting stupid errors
main code: (some part removed)
// Messenger class!
ref class Messenger : public Form
{
public:
static DWORD WINAPI listener(LPVOID lpParam);//line 26
SOCKET s;
bool conected;
HANDLE Handle_Of_listener;
Messenger()
{
InitForm();
if(ConnectToHost(1234,"127.0.0.1") == true)
{
printf("conected!");
conected = true;
HANDLE Handle_Of_Thread_1 = 0;
Handle_Of_listener = CreateThread( NULL, 0, listener, &s, 0, NULL);//line 38
}
}
static String ^myUsrName;
private:
// Win controls, Icon & Menu
RichTextBox ^ MessengerTxtR;
RichTextBox ^ MessengerTxtS;
array<Button^>^ MessengerButtons;
static String^ s_strZero = String::Format("0{0}0", System::Globalization::NumberFormatInfo::CurrentInfo->NumberDecimalSeparator);
System::Drawing::Icon^ m_pCalcIco;
MainMenu^ m_pMessengerMenu;
MenuItem^ m_pFileMenu;
MenuItem^ m_pAboutMenu;
MenuItem^ m_pExitMenu;
public:
DWORD WINAPI listener(LPVOID lpParam)//line 62
{//line 63
SOCKET s = (SOCKET)lpParam;
return 0;
}
error:
.\main.cpp(26) : warning C4441: calling convention of '__stdcall ' ignored; '__clrcall ' used instead
.\main.cpp(63) : warning C4441: calling convention of '__stdcall ' ignored; '__clrcall ' used instead
.\main.cpp(63) : error C2686: cannot overload static and non-static member functions with the same parameter types
.\main.cpp(26): could be 'DWORD Messenger::listener(LPVOID)'
.\main.cpp(62): or 'DWORD Messenger::listener(LPVOID)'
.\main.cpp(38) : error C2664: 'CreateThread' : cannot convert parameter 3 from 'DWORD (__clrcall *)(LPVOID)' to 'LPTHREAD_START_ROUTINE'
None of the functions with this name in scope match the target type
|
|
|
|