|
How can a program detect other instances of itself running simultaneously? In VC++ please
|
|
|
|
|
Search CP for "single instance". You'll get tons of articles about your question.
Best,
Jun
|
|
|
|
|
|
Hi,
I'm generating an html page on-the-fly in my application.
This page should contain images. The images i have in the DB are of formats that cannot be used in html (jpeg, png etc) so i need to save them in gif format.
Does anybody have a lead on how to save these image files in gif format?
Thanks in advance.
|
|
|
|
|
I guess you can open them in MS Paint and then save them to the bmp/gif format. Paint does the conversion.
Fortitudine Vincimus!
|
|
|
|
|
Sure, but but this has to be implemented on-the-fly. The DB is dynamic and i don't know in advance what's its content.
It has to be done in coding. Thanks anyway.
|
|
|
|
|
|
I suppose that depends entirely on what braindead (or not) browser you've got.
--
Presented in BC [Brain Control] where available
|
|
|
|
|
GDI+ is the simplest to use for image format conversions.
You simply load the image, set the encoder and save the image to file or stream. GDI+ is slow but it has proven itself to be very useful in terms of image manipulation and advanced effects.
It has a native C interface that Microsoft wraps with a C++ wrapper class. Be forewarned, if you come from an MFC background, their wrapper classes are somewhat frustrating and obviously designed by the Herb Sutter camp of "You should not be coding that way so we'll make it harder to shoot yourself in the foot" program team.
But, at the end of the day, it saved me tons of development time so I tend to overlook it's poor interface and still recommend it when performance is not critical.
|
|
|
|
|
bob16972 wrote: their wrapper classes are somewhat frustrating
I once worked with a guy who had been on the GDI+ team (or done some work for them; was never clear on that.) My first question was: Why?
His eventual answer was that the whole thing was essentially a proof-of-concept and never intended to be released.
My next question was whether Microsoft Engineers have to put up with designs like this for stuff that really is internal. I got no answer. (Given the horrific design of the TreeView and ListView controls, I suspect I knew the answer.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Joe Woodbury wrote: Why?
It is indeed an oddity why they didn't just add some additional flags to some GDI functions and a few new methods for the image manipulation routines.
At this point in the game, I'm glad the additional functionality is available somewhere since implementing routines for all the image file formats would have set me back a few more years.
Joe Woodbury wrote: never intended to be released
The sad part is, I was actually anticipating the next release of GDI+ for roughly a year until I came to my senses and realized they had indeed abandoned it's development in favor of the utilization of the DirectX layer that now is apparently underneath all the Vista graphics.
Live and learn.
:: sigh ::
|
|
|
|
|
libtiff
libjpeg
are decent places to start. You might have to write the code that dumps to gif, I dunno, but at least the first two will decompress to bitmap or something similar.
Why, again, do you think browsers won't read jpg or png?
earl
|
|
|
|
|
earl wrote: Why, again, do you think browsers won't read jpg or png?
When exactly did I say that? I think your post got linked incorrectly
|
|
|
|
|
Sorry, not you Bob, snir_ya
|
|
|
|
|
|
Hi,
I have used CdateTimeCtrl resource in my program (VC++, mfc) on a dialog box, which allows a user to select a date.
In the OnInitDialog() I have set the format as
m_DateStart.SetFormat("MM/dd/yyy");
Where m_DateStart is a CdateTimeCtrl object.
When I run the program in debug configuration, I get the error ‘the application has encountered a problem and will be shut down…”
But when I run the program in release configuration, no error appears.
Please can you tell me why this happens? What do I do? Should I ignore it…?
Thanks,
Tara
Fortitudine Vincimus!
|
|
|
|
|
TheinstruTara wrote: CdateTimeCtrl
TheinstruTara wrote: In the OnInitDialog() I have set the format as
Have you called
<font>m_DateStart.SetFormat("MM/dd/yyy");</font>
before CDialog::OnInitDialog or after!
"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
|
|
|
|
|
Its a property page actually.
This is how it is.
BOOL CSelectYear_PP1::OnInitDialog()
{
CPropertyPageEx::OnInitDialog();
m_DateEnd.SetFormat("MM/dd/yyy");
m_DateStart.SetFormat("MM/dd/yyy");
CDateTimeCtrl *a;
CDateTimeCtrl *b;
CWnd *c;
a = (CDateTimeCtrl*)GetDlgItem(IDC_DATETIMEPICKER1);
b = (CDateTimeCtrl*)GetDlgItem(IDC_DATETIMEPICKER2);
c = (CWnd*)GetDlgItem(IDC_BUTTON_Preview);
tip.Create(this);
tip.addtool(a,"Budget Start Date");
tip.addtool(b,"Budget End Date");
tip.addtool(c,"Preview display data type");
GetDlgItem(IDC_BUTTON_Preview)->EnableWindow(FALSE);
return TRUE;
}
Fortitudine Vincimus!
-- modified at 3:17 Monday 10th July, 2006
|
|
|
|
|
Hi,
I'm working with Microsoft WinFax in C++ (Win32) under Visual Studio 2005 in XP Pro, which is very easy to use. I already successfully connected to the FAX server with "FaxConnectFaxServer", sent a PDF document with "FaxSendDocument", and even editted and added a cover page. I checked all with the FAX console, which allowed me to see the FAX pages as well as all FAX'es pending. This all took me about 30 minutes, so I was very happy with it.
Then I began trying to evaluate how I could extract information about queued outbound and also inbound FAX information. The function to use, of course, is "FaxEnumJobs", which works fine. However, the amount of detail it returns seems to not be adequate for my purposes.
At this point I want to get access to the FAX pages while they are queued or after being received. This is where my problem begins.
The "FaxGetPageData" should return information only about the first page, excluding cover, which is not sufficient for me. I state "should" because, in fact, it returns an empty buffer for all the FAX'es I have queued (BufferSize is zero, but Buffer points to "LMEM").
So I tried relating the "JobID" I get from "FaxEnumJobs" to the names of the files on disk, to access them directly. I looked into "C:\Documents and Settings\All Users\Application Data\Microsoft\Windows NT\MSFax\Queue", and all my queued FAX files are there. Their names, however, have no obvious relation to the "JobID", so I don't have an easy way to access the files directly. Anyway, due to their ugliness, I would always consider these solutions extreme.
Does anyone have any idea on how to get queued complete FAX page data? I don't really need to interpret TIF files, I will just send them over through the WEB server for the client users to open in their browsers. The cleaner solutions are prefered!
Rilhas
|
|
|
|
|
I was not sure if this post should go into this forum, or the ADO forum. I think this might be the best for this situation.
We have a project that haven't yet been ported to VS.NET or VS2005 and we would like to use SQL Server Everywhere. It is only available through ADO.NET or OLE DB. OLE DB seems to be a bit complex for us at the moment, so I was curious if it is possible to use the ADO.NET assemblies through a wrapper from MFC in VS 6.0. The project is quite big, and takes a lot of time to convert to conform with the stricter compiler in VC++ in VS2005 and other changes. We need to make a choice on which database to use as we (as everyone) have a deadline. I was hoping it would be possible to use ADO.NET in MFC 6, but I guess that would be a quite long shot as you can't directly mix and match managed and unmanaged code MFC 6 (?). I one division in our company are using .NET user controls in the MFC 6 project, so I was hoping it would be possible to use ADO.NET there as well.
Ofcourse if I can find a good OLE DB library which is SIMPLE to use, something very close to the ADO providers in .NET, we can still use SQL/e. I tried Express OLE DB Library, but we have some difficulties compiling it, as well as we are unable to get the source and it is no longer supported (it seems).
Best regards
Bjørnar
|
|
|
|
|
You could probably expose ADO.NET assemblies through COM and then use it from VC6.
Having said that, I am not sure it is such a good idea. Have you looked at OLE DB template classes? If you don't like them, try SQLAPI++[^] - it has a OLEDB wrapper and looks really easy to use.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Hi there,
Has anybody out there had any experience of implementing a CTabCTrl system with the ability to have centre justified tabs ?, an example of the kind of system that i am looking to implement is one similar to the tab control system used on the amazon web sites.
Regards
|
|
|
|
|
Hi,
I wrote an application( simulator) that creates a textfile, with some lines of text in it. This same application also deletes this textfile after a couple of seconds. This process repeats itself over and over again. So the outputfile is present for lets say 5 seconds and gets deleted for about the same amount of time.
This simulation file gets created with the following code :
CStdioFile OutFile;
if (OutFile.Open(m_strOutFileName, CFile::modeWrite | CFile::modeCreate | CFile::shareExclusive))
{
...
}
Then I wrote a second application, which checks every 100 millisec if the simulation file is present, and if so reads it in and processes it. This is done with following statements :
int CTimer::Scan(CPLine *pPLine, LPCTSTR lpszPFInPath, BOOL bInBuf)
{
int nBCCnt = 0;
try
{
CString strBC;
CStringArray BufArr;
CStdioFile inFile(lpszPFInPath, CFile::modeRead | CFile::shareExclusive);
while (inFile.ReadString(strBC))
{
if (strBC[0] == _T('\"'))
strBC.Delete(0);
if (strBC[strBC.GetLength() - 1] == _T('\"'))
strBC.Delete(strBC.GetLength() - 1);
if (bInBuf)
BufArr.Add(strBC);
else
{
if (LookupBC(pPLine, strBC))
nBCCnt++;
}
}
inFile.Close();
if (bInBuf)
{
int nSize = BufArr.GetSize();
for (int i = 0; i < nSize; i++)
if (LookupBC(pPLine, BufArr.GetAt(i)))
nBCCnt++;
}
}
catch (CFileException *e)
{
e->Delete();
nBCCnt = -1;
}
return nBCCnt;
}
When I run both applications, I sometimes receive the follow message :
CFile exception: sharingViolation, File C:\WINDOWS\Temp\L7.dta, OS error information = 32.
First-chance exception in PCnt.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
What is wrong here and how can I prevent this error ??
tia.
|
|
|
|
|
paperke67 wrote: When I run both applications, I sometimes receive the follow message
If this is in your debug output window, it's just informaing you that your try/catch is working correctly. If your using the same filename/path for each application, then I would expect an exception to occur periodically as a matter of statistic.
You did not post a Try/catch with the first apps code but I'm guessing its around the actual code, otherwise I would expect an exception dialog box to pop up on you for the same reason.
Since you are simply ignoring the exception by deleting the CException pointer without reporting it, it would appear that suppressing the error is by design and what you intended so any indication of a first chance exception in the debug output window for file operations is likely just informative and should cause you no alarm or indicate any problems with your code.
-- modified at 15:16 Sunday 9th July, 2006
I guess I forgot to mention that based on what your doing, two apps are competing to open the same file exclusively and since there is no syncronization between the apps and there are certain lag times on file locking operations, that the exception is expected to occur and again is just the nature of the beast when dealing with files, databases, or any resource that could be unavailable for a moment based on inherent environmental conditions. One of the competing apps is bound to find the file locked from time to time and it is safe to simply ignore it, and try again on the next interval or timer.
NOTE: However, if the file remains locked indefinitely, You app will not indicate this problem to the user since it is happily ignoring the exception every time. You might want to keep track of failures and after some excessive period report an error to a log file or popup an error via the GUI.
|
|
|
|
|
OP: That's a terrible design.
You could, alternatively, do something like a circular buffer of files:
writer writes file data0001
reader reads data0001 and deletes
writer knows it last wrote data0001 so next time it writes data0002, on up to, say, 1000 then loops back to 0.
reader always deletes. This way, the two apps shouldn't get into a race over the same file.
Alternatively, there is a whole body of stuff called IPC for getting data from one process into another. The ones that come to mind are pipes, sockets, and perhaps mailslots.
earl
|
|
|
|
|