|
I have a full com serverwith three interfaces. A different client will access each of the three interfaces at overlapping times. I only want one instance of the .EXE to be running. As each of the client apps performs its _CreateInstance, a new instance of the app is launched. Giving me three altogether.
Is this possible?
How is it done?
I am familiar with the technique of using FindWindow and setting the focus to the already existing window to ensure only one copy of an app runs at a time. I don't think it applies here because 1) No window, the client apps are NT services. and 2) I don't think the interface would be attached if I simply re-directed the focus and exited.
Can anyone help, please?
Thanks for the help,
Bill
|
|
|
|
|
Try searching
http://discuss.microsoft.com/archives/atl.html
for singleton
Todd Smith
|
|
|
|
|
How can I launch multiple views fron one SDI and make them totally independent???
I can launch multiple views, but if I close the first one the others get closed!!
|
|
|
|
|
r u closing the view or closing the document ?
D.W.
|
|
|
|
|
Hi,
I am trying to write some VC++ code that will allow me to display a screen image at different resolutions (640x480, 1280x1024 etc) and then allow me to save at the chosen resolution (as BMP, JPG, GIF.)
Any assistance would be greatly appreciated!
Thanks
|
|
|
|
|
The problem is one of bit mapping. You must map the bits in your image to your display.
Your source image is a matrix of pixels of some size. This is independent of the resolution you wish to display it at. It may be larger or smaller than any one of your target resolutions. It may have a different shape. There are seveal problems to solve:
1) Decide the type of mapping you want: Clip, Stretch, Maintain aspect ration are the main ones.
2) Suppose you had a source image of 2000 X 2000 pixels. To display at 640 x 800, for example you must match 2000/640 bits to each bit in the display horizontally and handle the same situation veritcally (taking into account whether you want to preserve the aspect ratio or not). This operation must be done at each resoulution.
3) if you are mapping many pixels from the source to 1 in the display, you must compute some sort of average pixel value for each color. If you are going the other way, you need to interpolate each pixel from the values of the source pixels around it.
Saving the result can be done with the usual format specific algorithms. Its been a few years since I worked with this sutff, I've seen libraries of graphics sotware for reading and writing the various types of image files. The free ones were complicated and hard to use. The commercial ones cost money.
Good luck. Image processing is something very few want to get involved with. It is very labor intensive.
Hope this helps,
Bill
|
|
|
|
|
Hello,
I'm wanted to write an file output stream that outputs in the zip format. I wanted to do this by inheriting the new class (zofstream) from ofstream. However, I was a bit confuse as to ofstream's implementation. Here are my questions...
1) ofstream inherits from ostream, but none of the operators in ostream are virtual. How is it that you can use these operators with ofstream and have the data be directed to the file? I wanted to overload the operators for my own class, but how can I do that when the operators weren't declared virtual? (and I'd rather avoid having to make this a wrapper class). There's obviously a mechanism in place here that I'm not aware of.
2) Reading the ofstream's implementation source code would help, but I don't have it, and couldn't find it. Can anyone help me with that, if they can't answer question 1?
|
|
|
|
|
There's no need for the operators to be virtual. You just override whatever methods you want. The only time virtual comes into play is polymorphism - when you're accessing zofstream methods through a ofstream* variable and you need the zofstream version to be called. Folks don't usually use polymorphism with streams, so the ofstream methods aren't virtual.
The code is all in the "fstream" header I believe. Good luck understanding it, though, it's horribly obfuscated and impenetrable.
--Mike--
http://home.inreach.com/mdunn/
This posting is provided "as was" with no warranties, guarantees, lotteries, or any of those little bags of peanuts you get on planes. You assume all risk for crossing the street without holding mommy's hand. © 2001 Mike's Classy Software. Member FDIC. If rash develops, discontinue use.
your with and
|
|
|
|
|
The usual way to have user defined streams is not by deriving from ofstream or any other standard stream , but rather by deriving from streambuf , which is the holder of the virtual functions you're after. Only after this you can define your ozfstream as a derivation of ostream having a zstreambuf (or whaterever you decide to call it) as a member and attaching the base class to it. The details are a little convoluted, but the task if way simpler than your intended approach of overriding each and every ofstream method. Plus, you got some extra bonuses, like the possibility of having zipped streams of any kind, not just coming from files but from memory buffers or other sources.
Good luck with your project.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm having a hard time making a macro for my outputdebugstring function.
void CMyTrace::ODS(const CString& message, ...)
{
va_list args;
char textBuffer[1024];
va_start(args, message);
_vsnprintf(textBuffer, 1023, message, args);
va_end(args);
OutputDebugString(textBuffer);
}
I've tried something like this with no luck. I've searched and search to find a way. I know it can be done because micro$oft does it with ATLTRACE and TRACE but I'm not having any luck.
#ifdef _DEBUG
void ODS(const char* msg, ...) { .code. }
#define DEBUGOUT debugOut
#else
inline void ODS(const char* msg, ...) { /* empty */ }
#define DEBUGOUT 1 ? (void)0 : ODS
#endif
|
|
|
|
|
try this:
#ifdef _DEBUG
void ODS(const char* message, ...)
{
va_list args;
char textBuffer[1024];
va_start(args, message);
_vsnprintf(textBuffer, 1023, message, args);
va_end(args);
OutputDebugString(textBuffer);
}
#define DEBUGOUT debugOut
#else
inline void ODS(const char* msg, ...) { }
#define DEBUGOUT 1 ? (void)0 : ODS
#endif
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I know that is possible to draw a bitmap using SetROP2 in such a way that some of the bitmap's pixel to be transparent ( i.e. to be not copy onto screen ). But is there a way to draw a polygon onto screen and only pixels with some color to be touched ( i.e. changed ) by this operaion ?
|
|
|
|
|
Yes, you could just build the mask from the destination instead of the source bitmap. I *think* that would work. You could also turn it into a DIBSection if it isn't already and do it manually.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
How can I resize a view to be as big as a particular frame-window?
I have an app with multiple views in one frame-window. Off course, only one can be active. When I resize the window, all in-active views need to be resized as well. It does not happen automatically. How do I do that? I have pointer to all of them.
Thank You for your help,
XP
|
|
|
|
|
It seems to me that you could handle the WM_SIZE message in the frame class to capture when the window gets a new size. From there, you can resize the windows as you like by using MoveWindow on any views you wish to move or resize.
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
This works, but the view gets disconnected from the frame.
What I mean is, the view gets resized to the size of the frame, but it draws itself over the status bar of the frame. When I resize I can make parts of the status bar appear. The view seems detached form the frame although I called SetActiveView().
Any thought?
Thank you.
|
|
|
|
|
I'm working on an app that can change languages at run-time. It can be run in English, or Chinese (and many others, but for simplicity's sake I'll focus on those.)
Anyhow, this app works fine in English on an English system, and fine in English or Chinese on a Chinese system. Problem results when running in Chinese on an English system. The fonts are there, and IE can display them fine.
The problem is that most dialog controls (e.g., CStatic, CButton) will *not* display the Chinese text right, even if I select a Chinese-encoded font into the control. What I get are what appear to be the DBCS strings in ASCII or something. In spite of this, a CEdit with the same font in the same dialog will work just fine!
One more thing - if I make my own control derived from, say, CStatic, and override OnPaint to display text myself, it works.
Anybody know what gives? Will I have to override the default controls that don't happen to work (CStatic, CButton) with my own controls? Is this a problem with MFC, or the underlying Windows controls?
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
I worked with cirillycs Idiomas, Hebrew and Arabic with a application that changed from English to Portugesse or Spanish or hebrewm, or russia, etc.
For that I needed to work in a Hebrew operating system, The classes didn't work fine with these Idioms, I needed to work all in unicode, and when you tray to make a CWnd::SetWindoText, CString don't supports those characters. I needed to create every control with the Create function, etc....
Carlos Antollini.
Today is Friday!!! for All!!!
|
|
|
|
|
Well, what seems odd, is that, let's say I derive a control from CStatic (or make a custom control.) In my OnPaint handler, I have the code below, and it works fine! So it's not a problem with CString or Set/GetWindowText, or TextOut. It does make me wonder what a CStatic (or Windows static) control could possibly be doing that is messing this up??
<br />
CPaintDC dc(this);<br />
<br />
CString str;<br />
CRect rect;<br />
<br />
GetWindowText(str);<br />
GetWindowRect(&rect);<br />
<br />
CSize textSize = dc.GetTextExtent(str);<br />
<br />
int x, y;<br />
x = rect.Width() / 2 - textSize.cx / 2;<br />
y = rect.Height() / 2 - textSize.cy / 2;<br />
<br />
dc.SetBkMode(TRANSPARENT);<br />
dc.SelectObject((CFont *)GetFont());<br />
dc.TextOut(x, y, str);<br />
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
Hi...
just few simple questions:
1. how do u call an application in your VC++ project? e.g. I want to call real player.exe in my project.. what's the command?
2. What's the command to copy one file? e.g. I wanna copy pic.bmp to c:/image/pic.bmp
3. How do I know what's my current working directory?
Thanks a LOT....
|
|
|
|
|
|
1- CreateProcess();
2- CopyFile()
3- GetCurrentDirectory();
Cheers
Carlos Antollini.
Today is Friday!!! for All!!!
|
|
|
|
|
MSDN has all these functions, although these types of functions are typically Windows API, and not wrapped in any way by MFC.
For running a process, there are a couple others:
1. ShellExecute: it is nice if you have a program's date (e.g., a RealPlayer file) and want the system to find the app that handles it.
2. CreateProcess: if you want full control over creation, but it is probably the most complicated of the ways to run a program.
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
I have a property sheet, and one property page (CFirstPage). m_showInfo is a bool, and m_ctrShowInfo is the DDX control for the checkbox. I want to initialise the property page with the current settings.
In my implementation file;
CFirstPage::CFirstPage() : CPropertyPage(CFirstPage::IDD)
{
if(m_showInfo)
m_ctrShowInfo.SetCheck(1);
else
m_ctrShowInfo.SetCheck(0);
}
If i use SetState() instead, everything goes well. However, SetCheck() crashes at CButton::SetCheck. Any ideas why?
---
"Transmit in all known frequencies and in all known langauges, including Welsh."
|
|
|
|
|
because m_ctrShowInfo isn't a "window" yet, and SetCheck is sending a window message.
try setting this in your InitDialog
-c
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|