|
how can i stop my application from freezing when its processing a function?
any help will be greatful. Thanks.
|
|
|
|
|
put it inside a thread... look up CreateThread on Platform SDK or check out one of the system sections on CP
- Roman -
|
|
|
|
|
got any examples on CreateThread?;P
|
|
|
|
|
You should rather use _beginthread[ex]. Look in MSDN for example.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I am facing two problems:
1) displaying and scaling image files of *.TIFF, *.BMP, *.JPG formats
2) conversion of grayscale images into bitonal representations (smaller size, better compression).
Does anyone know about any cool open source graphics libraries, algorithms, etc...
Thanks a bunch in advance.
Kirill
|
|
|
|
|
Hi,
Try this url. It gives you all the information that u need. In fact the whole application does exactly what u want.
http://www.codeguru.com/bitmap/CPicture.html
I suggest you use GDI+ libraries. They are really to use and you can save,load and modify the images much more easily compared to the method used by the author of CPicture class.
Einstein's Assistant
|
|
|
|
|
I've done a series of articles on image processing in GDI+ which will tell you everything you need to know, here on CP.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
I am trying to dynamically size the column widths of a MSFlexGrid control. Presently, the code I'm using is this (which was hard enough to figure out):
CDC * dc;
dc = this->GetDC();
dc->SetMapMode( MM_TWIPS );
CRect rc;
m_TheGrid.GetClientRect( &rc );
dc->DPtoLP(&rc);
int Width = rc.Width() / (CellsPerRow + 1);
m_TheGrid.SetColWidth(1, Width );
Width = m_TheGrid.GetColWidth(1);
for ( int i=1; i < CellsPerRow+1; i++ )
{
m_TheGrid.SetColWidth(i, Width );
}
int Remainder = rc.Width() - Width * CellsPerRow;
m_TheGrid.SetColWidth(0, Remainder );
What I've noticed is that even though I set a particular size like this:
m_TheGrid.SetColWidth(1, 332);
the size read via GetColWidth() is usually something different, like 330. That isn't too much of a problem, since I set one column, read what was actually set, then set all the columns (except the first one) to that value. I then account for errors by putting the remaining size into the first column.
BUT:
The size that is returned by the GetClientRect() call does not encompass the entire space available. That is, when I've got all my columns layed out, I still have stubstantial space available on the right.
I was halfway expecting to have LESS room because of a scroll bar. But the size reported by GetClientRect() underreports.
Does anyone have an idea about what is happening here?
I don't think it should matter, but I've set the font in this control to fixedsys.
Ron
|
|
|
|
|
Hi,
given:
CStringArray* pArray;
CStringArray aArray;
and I have useful data in pArray. Now I want to accumulate multiple pArray's in an aArray.
aArray.Append(pArray)
but the argument of CStringArray::Append requires a CStringArray& not a CStringArray*.
How can I cast it?
Thank you
R.
|
|
|
|
|
aArray.Append(*pArray)
-c
Cheap oil. It's worth it!
|
|
|
|
|
|
"A duplicate insert block exists for class "CMainFrame" in the source files"
I get this error message when I open up the classwizard for CMAinFrame class. Any information?
|
|
|
|
|
Looks like you have //{{AFX.. comments which clas wizard uses duplicated in your header or source files. Search for these and remove them.
|
|
|
|
|
I have a MDI application where I want to have only one open document at any given time. There are several different types of views, so it therefore gets confusing with many open documents as well.
So, thanks to a helpfull CPian I eventually managed to block OnFileOpen() and OnFileNew() if a file is already open. But the MRU list is still active. How can I disable it if I don't want it to show up?
Haakon S.
|
|
|
|
|
Change the call to LoadStdProfileSettings() in your application's initialisation function to LoadStdProfileSettings(0).
Regards,
Jason Wilden.
|
|
|
|
|
Thank you for pointing in the right direction. But I'm not entirly happy with your proposal. I want to retain the MRU list if no file is open, and to disable it only when there is an open file. Calling LoadStdProfileSettings(0) will do away with the MRU list altogether.
Anyway, I've discovered that there is something called CRecentFileList::UpdateFileList(). I'll do some scruteny here.
Regards, Haakon S.
|
|
|
|
|
You could also delete it from the menu in the resource editor.
Best regards,
Alexandru Savescu
|
|
|
|
|
To eliminate the menu items, simply remove the ID_FILE_OPEN, ID_FILE_NEW and ID_FILE_MRU_FILE1 menu items from the the menu associated with you document template, but leave them in the default menu IDR_MAINFRAME (which is used when no document is active). You will also need to add a pair of ON_UPDATE_COMMAND_UI() handlers to your CDocument derived class to disable the ID_FILE_OPEN and ID_FILE_NEW commands when a document is active (this will prevent them being invoked via toolbar buttons or accelerator keys). When no document is active, you'll get the default behaviour (they will be enabled, since a handler function is defined).
Stephen C. Steel
Kerr Vayne Systems Ltd.
|
|
|
|
|
|
I assume that you are talking about the CListCtrl...If you are using CListView then you can get a pointer to the underlying CListCtrl by calling GetListCtrl.
CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTCONTROL);
POSITION pos = pList->GetFirstSelectedItemPosition();
while (pos)
{
// item is the list index
int nItem = pList->GetNextSelectedItem(pos);
// now you can use GetItem to get information
}
|
|
|
|
|
Thanks. But how is it done without using MFC? I'm talking about the "List Control" you can add to your dialog in the resource editor.
THanks
|
|
|
|
|
|
I'm currently working on a plugin system for an application I'm writing and I'm a bit confused as to why MSVC++6 requires the DLL to have all external symbols resolved.
For instance, lets say a function PluginInit() in my plugin calls a function SetName() that is part of the executable. I am currently required to link the DLL with the .obj file from my main program that defines the function SetName() .
Is there any way to get the linker to not resolve all of the symbols untill runtime? dlopen() on Linux does this with shared libraries. If not, the only way I can think of calling these functions is by using function pointers which would be a total mess. For instance:
----
in main application header file:
void SetName (char* name);<br />
void (*SetNamePtr) (char* name);
somewhere in initialization of the application:
SetNamePtr = SetName;
and then in my DLL:
SetNamePtr ("Plugin Name");
----
Is there a better way?
Thanks for all of your help,
Chris
|
|
|
|
|
I think a better solution for you would be to place the functions which Plugins can call in another shared library (DLL) and link both the applications and plugins with that.
In current case when you are linking the applications obj with the dll, a separate copy of code exists in the dll and in the exe.
|
|
|
|
|
Chris Testa wrote:
Is there a better way?
There's always a better way.
One technique I've had good experience with is as follows. Since the application is the one loading the plugin DLL's, give the DLL's init function a pointer to an object containing only virtual function pointers. A small example:
// app header
class AppInterface
{
virtual void DoSomething();
virtual void DoSomethingElse();
};
// app code. Assumes class AppFoo implements the
// AppInterface interface.
AppInterface* p = AppFoo::Instance();
typedef void (*pfn_init_t)(AppInterface*);
hDll = LoadLibrary(...);
pfn_init_t pfnInit = GetProcAddress(hDll, ...);
(*pfnInit)(p); // Calls the DLL's init function, giving it a pointer to the AppInterface interface to play with.
|
|
|
|