|
The behavior looks weird because the dialog's parent window is hidden.
You could
a) Restore the main window then show the dialog
b) Don't restore the main window and use NULL for its parent window
c) Don't restore the main window, create the dialog, but don't show it
If you go with c), make sure the visible style is turned off in the dialog resource.
|
|
|
|
|
Thanks for a VERY quick answer, Mike!
I'll have to see what my my options are here and select the best one. I have thought about a), but not all these windows are probably such that they should restore the main window. I really didn't come to think of the main window being hidden, but of course it is! The button on the start menu isn't really the main window, but just a thingy representing it.
-Pete
|
|
|
|
|
hey my dear code project members,
i am having a problem trying to know the length of a wave file
i tried
mciSendCommand(wDeviceID,MCI_STATUS,MCI_TRACK | MCI_STATUS_LENGTH ,(DWORD)(LPVOID) &mciStatusParms);
actually i don't know how to initialize the MCI_STATUS_PARMS "mciStatusParms"
to get the length (duration) of the wave file
so is this the right way and how can i get it work
if it is not, wat is the right way to get the length of a wave file
thnx alot 4 ur time and concern
|
|
|
|
|
May it be a LAN or internet, How do we detect it? using VC++? anyway through Winsock?.
?
|
|
|
|
|
Check out InternetGetConnectedState()
|
|
|
|
|
Thanks Mike, and do we have any similar function in .net?
?
|
|
|
|
|
I have a class which is compiled to a DLL. When giving out the DLL, i give along the .h, .lib and .dll files.
.h File content (implementation in .cpp compiled to .dll and .lib)
class DLLTESTV_API CDLLtestV {<br />
public:<br />
CDLLtestV(void);<br />
int GetX();<br />
void SetX(int _X);<br />
private:<br />
int x;<br />
};
But, i do not want the end user to know any private members of my Class. Is there anyway
i can hide those? The private members are in the private: block in the .h file and are visible in my class declaration.
I want to ship .lib, .dll and .h like this
class DLLTESTV_API CDLLtestV {<br />
public:<br />
CDLLtestV(void);<br />
int GetX();<br />
void SetX(int _X);<br />
};
I have tried doing so (by deleting manually the private : int x line in the .h file used in a test program), and the programs executes fine but causes an error at the end. Removing that line causes a stack corruption error during runtime (with the compiled DLL in a test program).
Any suggestion how i can hide the private members (users cant modify them anyway, they are private!).
|
|
|
|
|
The way it is done generally is to provide an interface only: make your CDlltestV class inherits from an interface class (IDlltestV for example) which exposes only the public functions as pure virtual:
class DLLTESTV_API IDLLtestV {<br />
public:<br />
CDLLtestV(void);<br />
virtual int GetX() = 0;<br />
virtual void SetX(int _X) = 0;<br />
};
Then in your dll, you simply make CDlltestV inherits from this interface and you provide there the members and implements the functions.
The 'problem' is that you'll need to provide a function to will create an instance of this class and return a pointer to your interface:
DLLTESTV_API IDlltestV* GetClass()<br />
{<br />
return new CDlltestV;<br />
}
But if your code is well written, this shouldn't pose too much problems.
|
|
|
|
|
To Quote Marshall Cline : "Encapsulation is for code, not for people". You shouldn't try to hide it. The statement private says all there is to say. The best way to enforce proper use is to put all public functions into an abstract base class ("Interface"), derive from it, declare the constructor private and create a class factory that only returns pointers to the ABC. But people will allways see what's in there if you give out the headers. See here : How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?[^]
|
|
|
|
|
how about using a privite implementation, aka PImpl ?
in your header you make reference to a private class that is declared and defined in the source file:
in pseudo-code.
class MyClassImpl;
class MyClass
{
private:
MyClassImpl* m_pImpl;
public:
void DoSomething(){m_pImpl->DoSomething;};
};
class MyClassImpl
{
public:
void DoSomething();
protected:
};
|
|
|
|
|
The problem is that the header defines not only the object interface, but also the size.
By building the dll with one header (with private members) and building an exe with another (no private members) you are using a different a sized object in the exe. At best you will experience what you have - runs with error at end. Most likely the program would be corrupting data everywhere.
uus831 wrote: Any suggestion how i can hide the private members (users cant modify them anyway, they are private!).
This isn't true, all non-const data can be modified, private is just the class developer attempting to create a contract with other developers who use the class. Another developer can just mod your header and replace private with public, now they can compile/link without warnings/errors and modify the (originally) private members however they want.
So, your choices:
1. Include a dummy private variable (byte array) that is the same size as all your private/protected members (including padding due to alignment). This can be tricky and is not recommended.
2. Export as an interface, as others have suggested.
3. Export with full header, as most people do/suggest.
[EDIT]
4. As Maximilien suggested, or even easier, just have a pointer to a private state struct.
e.g.
struct Apvt;
class A {
Apvt *pvt;
public:
A( void );
~A( void );
...
};
typedef struct Apvt {
...
} Apvt;
A:: A( void ) { pvt = new Apvt; }
A::~A( void ) { if(pvt) delete pvt; pvt = NULL; } This is actually a fairly common method that i've seen and used before.
[/EDIT]
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thank you so much guys! Works exactly like I wanted it to! The private struct technique is the easiest. Now i'm going to try the interface way.
Thanks again.
Really appreciated it!!
|
|
|
|
|
LONGLONG Date; //number of 100ns intervals since January 1st 1601 at * 00:00 UTC
How can i convert this to COleDateTime (or some other date structures)
I don't believe in failure. It is not failure if you enjoyed the process.
|
|
|
|
|
... FILETIME Structure Link[^]
I don't believe in failure. It is not failure if you enjoyed the process.
|
|
|
|
|
Hi to all,
in one of my applications ,i have to add a treeview to a combobox,
i searched a lot to find an article on this, but unable to find.
plz friends suggeswt me,or provide the url on how to add treeview to a combobox
thx in advance
Nagaraju
|
|
|
|
|
|
Hi..
I want to write a SMTP protocol using sockets....can any one suggest me.
Thanks
-murad
|
|
|
|
|
Abbas Murad wrote: I want to write a SMTP protocol using sockets....can any one suggest me.
Learn the Simple Mail Transfer Protocol[^] and implement it using sockets.
|
|
|
|
|
|
Hi,
I have a question regarding serial I/O.
...
I have been programming in MFC to interface Serial Ports
in Windows NT in order to read/write them in Overlapped as well as
in non-overlapped mode.
...
It worked fine all the time.
...
But I have a question regarding serial port.
...
That,
1) I open COM1 port in non-overlapped (Blocking I/O) mode
2) I Create a seprate thread, in which I attemp to read five Characters.
using "ReadFile" function.
3) Now, this function will not return unless I get all the five Characters
(As I have forced the "Read Timeouts" and "Write Timeouts" in
COMMTIMEOUTS structure to zeros)
4) But in case if I want to abort without further waiting for the arrival
of characters, I would have to abort the thread "Pre-matureally" ...
5) How can I do this, since the thread is simply blocked in waiting for
characters, as the "ReadFile" function has still not returned.
6) The application window closes, but the Thread keeps on running behind.
...
Basically I want my thread to terminate alongwith when application terminates.
But I dont get it through...
...
I will be very thankful for your assistance ...
...
|
|
|
|
|
There are only two ways for a call to ::ReadFile() on a serial device to return when opened in non-overlapped mode:
1. the device has received the number of bytes you wanted to read
2. there was a timeout due to the COMMTIMEOUTS settings, either there was too much time between two consecutive bytes or the whole operation took too much time to complete
There is no way to get passed this because this is how the system works.
It would be tempting to look at ::CancelIo(), but it can only be used in overlapped mode and by the thread that issued the read request.
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
Abruptly, you can call the TerminateThread from the main thread.
Or (better) you can handle all that stuff using OVERLAPPED I/O.
|
|
|
|
|
When I use Adobe PhotoShop's Crop Tool. It creates a subwindow helping me to select image scope. The subwindow attract me for its frame line looks moving. And I hope that there will be such a window in my application.
anyone can help me ?
|
|
|
|
|
when we use mouse to select some text on windows?
for example, we select some text in notepad application
i want to get the current selected text,
I does not want to simulate ctrl+c hotkey to copy data to clipboard(read data from clipboard),
i think this is very foolish,
I want to known whether some COM interface for us to use??? thanks again..
|
|
|
|
|
Not sure. But see if GetWindowText() is going to be of any use.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|