|
If you're not using MFC, the following would be the code, where hDlg is the handle to the dialog hosting the button -
::SendMessage(hDlg, WM_COMMAND, (BN_CLICKED << 16) | IDC_BUTTON1, ::GetDlgItem(hDlg, IDC_BUTTON1);
If you're using MFC, the following would be the version if you're calling it from within the dialog class -
SendMessage(WM_COMMAND, (BN_CLICKED << 16) | IDC_BUTTON1, GetDlgItem(IDC_BUTTON1));
|
|
|
|
|
ERROR,parameter 3...
SendMessage(WM_COMMAND, ((WPARAM)BN_CLICKED)<<8|(WPARAM)IDC_BUTTON, 0L); is that right?
I want the Button will be clicked down when the Message send,but there's nothing happened with the Button while the Message sent ,why
|
|
|
|
|
If you want to emulate a human pressing a button, then you will have to perform the actions a human performs:
1. Press button: send WM_LBUTTONDOWN
2. Hold button down a while: use SetTimer() or similar to implement delay.
3. Release button: send WM_LBUTTONUP.
|
|
|
|
|
Why did you not use the code that Superman posted? Re-read his answer and select the appropriate one (MFC or non-MFC) and use copy & paste to add to your project.
The best things in life are not things.
|
|
|
|
|
I got a error with it in my MFC app
Error 1 error C2664: 'CWnd::SendMessageW' : cannot convert parameter 3 from 'CWnd *' to 'LPARAM'
|
|
|
|
|
Just use a cast thus:
SendMessage(p1, p2, (LPARAM)p3 ...
You should really study and understand these basics of C++ before embarking on advanced projects such as you describe.
The best things in life are not things.
|
|
|
|
|
yea,I use
SendMessage(WM_COMMAND,(BN_CLICKED)<<16|IDC_BUTTON1,(LPARAM)GetDlgItem(IDC_BUTTON1));
it's passed in Compiling but pop up a Assertion Failded when running
> mfc100ud.dll!CWnd::OnCommand(unsigned int wParam, long lParam) Line 2708 + 0x27 bytes C++
so I changed it in Release Configuration,no Assertion Failed pop up ,why?
|
|
|
|
|
asserts don't get compiled in release code - they are a debugging tool and have little value in release code - i.e. the problem is still there in release code, you just didn't get a popup
In that code nugget the assert could be caused by an invalid window, are your sure that the window you are in is the immediate parent of the button
you'd normally be in a CDialog... class for this to work
|
|
|
|
|
What are the values of wParam and lParam , and what assertion did you receive?
The best things in life are not things.
|
|
|
|
|
NO.
Just send BM_CLICK (!)
|
|
|
|
|
hi all....! i got a project to make compressor like winrar on mfc which can compress or decompress any file.... pls let me know what i have to do for it.....! how to start it ...!~
|
|
|
|
|
You could start off by reading about Data Compression[^], and when you have a specific question ask again here.
|
|
|
|
|
hmaz4629 wrote: i got a project...
Personal or school?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
|
Ok, so what preliminaries has your instructor given? Since academic coding is usually comprehensive, what other assignments have you completed that this one will build upon? Have you asked your instructor for guidance?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
well my constructor just told me that you have to make a compression on mfc and the thing you will use is to assign lowest frequency to the highest occuring number or digit or character or anything .
the code type you have to write is called huffman code
it is a type of tree which has branches
mean each linklist bo have link of two next boxes.
i have started using MFC week ago
and i have chosen this project because i need bonus to improve my grade
|
|
|
|
|
hmaz4629 wrote: well my constructor just told me...
When your constructors start talking to you, it's time for a break!
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Since you have posted the question in MFC forum i think you WANT CODE IN mfc.Read about data compression and look at this opensource compressor for reference.(learn and develop don't copy it )
7 ZIP:
http://sourceforge.net/projects/sevenzip/[^]
|
|
|
|
|
yeah i wanna learn not to copy thanks
|
|
|
|
|
hmaz4629 wrote: how to start it
I usually start projects using the File/New/Project menu command. Have you tried that yet?
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
In the past I have often had to do this - ie compress data/files. The best way is to use zlib as it is a defacto standard, open-source, unencumbered by any patents/licensing limitations and is supported in a large number of languages and environments. See http://zlib.net/[^].
You can also use my open source hex editor to play with all the options and features without writing any code. See HexEdit - Window Binary File Editor[^].
Andrew Phillips
http://www.hexedit.com
andrew @ hexedit.com
|
|
|
|
|
Please clear the below confusion;
1. Can you call "delete this;" inside a member function?
2. If Yes, What can you do after calling delete this?
|
|
|
|
|
It is allowed, but wreaks all kind of havoc depending on what the next statements are in your code.
An object instance didn't instantiate itself, so it should neither delete itself. There might still be refernces pointing to said ojbect instance which would become undefined if the object instance would delete itself.
Best Regards,
-MRB
|
|
|
|
|
u can do this but after this you cant access that mamber function or veriable which is being deleted....!~
|
|
|
|
|
hmaz4629 wrote: u can do this but after this you cant access that mamber functio
Technically that depends on the exact nature of the function and maybe the compiler.
I say maybe because I would suppose that most C++ compilers are going to generate static bindings for non-virtual methods simply because it produces faster code.
hmaz4629 wrote: or veriable which is being deleted..
That is certainly unsafe but the actual impact depends again on the compiler and what the variable is and how the application works.
|
|
|
|