|
And a more thing if you have a variable for your button you can use m_Button.SetWindowText(""); if you dont have you can use of GetDlgItem(IDC_BUTTON1)->SetWindowText("");
|
|
|
|
|
Alright, well, that code worked perfectly. But now I need some way to make sure the button knows when to switch. I was thinking some code like
'if (counter == 1)
{
m_Counter.SetWindowText("Stop")
counter = 2
}
if (counter == 2)
{
m_Counter.SetWindowText("Start")
counter = 1
}'
The problem with this is, this relys on me setting one as the default value immedietly, and I don't know how to do that =/
|
|
|
|
|
I've used the CreateDibSection function to create a DIB for bitmap...
HWND hWnd = this->GetSafeHwnd();<br />
HDC hdc = ::GetDC(hWnd);<br />
<br />
BITMAPINFO bmpInfo;<br />
<br />
ZeroMemory(&bmpInfo,sizeof(bmpInfo));<br />
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);<br />
bmpInfo.bmiHeader.biBitCount = 8;<br />
bmpInfo.bmiHeader.biCompression = BI_RGB;<br />
bmpInfo.bmiHeader.biSizeImage = 0;
bmpInfo.bmiHeader.biPlanes = 1;<br />
bmpInfo.bmiHeader.biHeight = 768;<br />
bmpInfo.bmiHeader.biWidth = 1024;<br />
bmpInfo.bmiHeader.biClrUsed = 256;<br />
<br />
hFrameBitmap = CreateDIBSection(hFrameDC, &bmpInfo, DIB_RGB_COLORS, &pBits, NULL, NULL);
I'm wondering how I can set the 4th parameter to point to a FILE* type which I store my raw pixel data, where pBits must be a LPVOID.
Thanks
|
|
|
|
|
Hi folks!
Did you ever use System Console Software?
If no, try it now. Very interesting approach to scalable and amazing features for every day ( www.syscon.tsoftech.com ).
|
|
|
|
|
I use codeblocks + wxdgets
and try a sample
but get the following
:: === t3, Debug ===
D:\wxWidgets-2.8.3\include\wx\platform.h:14: warning: "/*" within comment
D:\wxWidgets-2.8.3\include\wx\platform.h:14: warning: "/*" within comment
D:\wxWidgets-2.8.3\include\wx\platform.h:14: warning: "/*" within comment
D:\wxWidgets-2.8.3\include\wx\msw\dde.h:100: error: `wxDDEConnectionList' declared as an `inline' field
D:\wxWidgets-2.8.3\include\wx\msw\dde.h:100: error: expected `;' before '&' token
D:\wxWidgets-2.8.3\include\wx\msw\dde.h:105: error: expected `;' before "protected"
D:\wxWidgets-2.8.3\include\wx\msw\dde.h:108: error: `wxDDEConnectionList' does not name a type
D:\wxWidgets-2.8.3\include\wx\msw\dde.h:130: error: `wxDDEConnectionList' declared as an `inline' field
D:\wxWidgets-2.8.3\include\wx\msw\dde.h:130: error: expected `;' before '&' token
D:\wxWidgets-2.8.3\include\wx\msw\dde.h:135: error: expected `;' before "protected"
D:\wxWidgets-2.8.3\include\wx\msw\dde.h:137: error: `wxDDEConnectionList' does not name a type
D:\wxWidgets-2.8.3\samples\minimal\minimal.cpp:163: error: `menuBar' undeclared (first use this function)
D:\wxWidgets-2.8.3\samples\minimal\minimal.cpp:163: error: (Each undeclared identifier is reported only once for each function it appears in.)
:: === Build finished: 10 errors, 3 warnings ===
why?
|
|
|
|
|
cform0 wrote: why?
What exactly are you asking "why" to?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
cform0 wrote: why?
Why NOT fix the warnings and errors one by one?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
cform0 wrote: why?
Your question is why you get these errors?
|
|
|
|
|
Hi,
So here's my problem: In certain circumstances, I want to stop my application from being closed when the "X" Windows sysmenu button in the top right corner of the application is pressed.
How can I do this? I tried catching the WM_DESTROY message and not running a PostQuitMessage(0) but this only leaves the process running; the application window is still destroyed.
Thanks in advance!
KR
|
|
|
|
|
If working with a dialog application, you can catch the command notification from the IDCANCEL button, which is what the [X] is on a normal dialog box.
I am not certain, but I think that the [X] generates a WM_SYSCOMMAND message with a SC_CLOSE notification, so you should be able to intercept WM_SYSCOMMAND .
In fact, you might be able to do the same for dialogs...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Catching WM_SYSCOMMAND with SC_CLOSE works, thank you.
KR
|
|
|
|
|
KellyR wrote: How can I do this? I tried catching the WM_DESTROY message and not running a PostQuitMessage(0)...
Did you try to simply return 0?
KellyR wrote: ...the application window is still destroyed.
That's because the WM_DESTROY message is sent after the window has been removed from the screen. Try WM_CLOSE instead.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
... simply return nothing.
--
=====
Arman
|
|
|
|
|
I've tried that, it doesn't work; the application process continues to run but the window closes.
KR
|
|
|
|
|
CWnd::OnDestroy() is a void function...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James R. Twine wrote: CWnd::OnDestroy() is a void function...
Yes, but MFC was not mentioned in the OP. The WM_DESTROY message does expect a return value, however.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all:
I have some experience using C programming, but for C++, so many libraries have been added to it.
The task I am supposed to perform is to check if a text file can be opened, which is input a command in line parameter, e.g. argv[1].
The first line of code given by my lecturer is:
ifstream in(argv[1], ios_base::binary);
I am stuck right here. Am I supposed to check the return value of ifstream? Or am I supposed to employ a member function of ifstream, but which one?
Thank you.
|
|
|
|
|
Generally, you need to learn C++ to fully understand what is happening. Anyway, the code is simple and a common way of opening a file [well, trying to open].
ifstream in(argv[1], ios_base::binary);
Here you declare and define an object whose type is ifstream. ifstream is a class responsible for file input operations. You pass the path and an optional ios::binary arguments to its constructor. Ok, to check whether the operation succeeded, you can do one of the following;
if (in)
{
}
if (in.is_open())
{
}
In the first case, the overloaded operator bpol gets invoked implicitly. In the second case, you explicitlly call a function [which returns bool].
--
=====
Arman
|
|
|
|
|
|
C_Zealot wrote: ifstream in(argv[1], ios_base::binary);
That line constructs an instance of the ifstream class as a variable called in , passing two parameters (argv[1], ios_base::binary ) to the constructor.
You then use the members of in to manipulate the data contained in the file referred to by argv[1] . You will have to take it upon yourself to lookup information on the ifstream class to see how you should use it.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
|
C_Zealot wrote: Or am I supposed to employ a member function of ifstream, but which one?
Have you tried is_open() ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
C_Zealot wrote: I am stuck right here. Am I supposed to check the return value of ifstream? Or am I supposed to employ a member function of ifstream, but which one?
You need to check if ifstream in is a valid stream. It's an object so you need to call it's is_open() , good() , or bad() function.
if(!in.is_open())
cerr << "File didn't open correctly!";
if(in.bad())
cerr << "File bad bit is set!";
if(!in.good())
cerr << "File is not good for use!";
You can also just do:
if(!in)
cerr << "File didn't open correctly!";
Which I believe checks if the file opened, but does NOT check if the any of the bad bits are set (could be wrong).
I recommend the in.good() approach, personally, as it checks everything for you.
My favorite pure C++ reference site. Goes great alongside MSDN.
http://www.cplusplus.com/reference/iostream/ifstream/[^]
Good luck
-- modified at 14:41 Wednesday 23rd May, 2007
|
|
|
|
|