|
I'm guessing that the image processing is done in a different thread than the main application so as to keep the GUI 'snappy'.
If so, there could be an issue with one thread manipulating a window created by another (the main app) thread. This could cause the app to screw up at random. I have seen similar effects related to this before.
I would suggest that the image thread post (not send) a message to the window. The app thread can then update the variable and call UpdateData(FALSE).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Having bint a DataGrid to a data source,I want to modify each colunm's width of DataGrid,what to do next? I tried as below but failure:
CColumns cols=m_DataGrid.GetColumns();
CColumn col;
VARIANT var;
long l=cols.GetCount();
for(long i=0;i
|
|
|
|
|
Hi,
I've been working on an image based application. I'm using VB and VC++ to work with the images. Both are activex controls. I created a property like Get/SetActivePicture(LPPICTUREDISP pPicture). The code is given below.
I'm facing memory problems. Can someone help me how can I release the memory from VC++ after I use the picture object? Thanks in advance .. I can't release the component until I solve this issue. Pls. somebody help me.
The implemenation in VB is like this ... After using this, the virtual memory has been increasing each time ... the performance became too slow !!!
....
PicEd.Open("C:\Temp.bmp")
set PicEd.ActivePicture = Picture1.Picture
PicEd.RotateBy(90)
set Picture1.Picture = PicEd.ActivePicture()
....
//----------------------------------------------------------------------
void CPicEdCtrl::SetActivePicture(LPPICTUREDISP newValue)
{
// TODO: Add your property handler here
if (newValue == NULL) return;
try
{
HBITMAP hBMP;
HRESULT lResult;
newValue->AddRef ();
m_Pic.SetPictureDispatch(newValue);
newValue->Release();
lResult = m_Pic.m_pPict->get_Handle((OLE_HANDLE FAR *) &hBMP);
//CxImage* image;
image->CreateFromHBITMAP((HBITMAP)hBMP);
}catch (CException e)
{
e.ReportError();
e.Delete();
}
SetModifiedFlag();
}
// ------------ ---------------------- --------------- ------
LPPICTUREDISP CPicEdCtrl::GetActivePicture()
{
// TODO: Add your property handler here
if (image == NULL)
{
m_Pic.CreateEmpty();
goto EndProp;
}
try
{
m_Pic.CreateFromBitmap (image->MakeBitmap(0));
}catch (CException e)
{
//Suppress any exceptions
e.Delete();
m_Pic.CreateEmpty();
}
EndProp:
//return the IPicture dispatch interface
return m_Pic.GetPictureDispatch();
}
|
|
|
|
|
I am new to (attempting) to use template classes.
My requirement is to avoid coding using inheritance - becuae I have 13 classes already coded and I want to have two "new forms" of classes that "inherit" this class and another class. To clarify...
I have a class X and I wish to make a class publishedTrack and a class reflectedTrack.
For example: I was hoping to use
typedef PublishedObject< Track > PublishedTrack ;
PublishedTrack* publishedTrack = new PublishedTrack;
where
template < class T >
class PublishedObject
{
private:
p_;
public:
PublishedObject();
virtual ~PublishedObject();
operator T*(void) { return p_; }
T& operator*(void) const { return *p_; }
T* operator->(void) const { return p_; }
PublishedObject& operator=(PublishedObject<t> &p_)
{ return operator=((T *) p_);}
PublishedObject& operator=(T* p_)
{ p = p_; return *this; }
T* get() const { return (T*)p_; };
}
I also want to be able to do publishedTrack->someMemberFunctionInTrack()
But what I get is that my operator overloading of -> is not quite right.
Any advice...any "pointers" ?
|
|
|
|
|
This is just a wild guess but perhaps instead of overloading the -> operator you could try overloading the . operator? ... Like I said, a wild guess...
|
|
|
|
|
Anyone know where I can get my hands on some C/C++ (not Java) code to control an X10 device? I just want to be able to turn the device on and off by running a simple command line program, eg:
C:\> foo.exe ON
C:\> foo.exe OFF
There seems to be nothing available @ x10.com or SourceForge.
Thanks!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
How do I convert a CString into a DWORD or to a INTEGER.
Basically suppose I have a function that returns a DWORD value , but the acutal value that I need to return is in a CString. (actually ...it is a number between 0 - 100)
suppose...
DWORD myfunc()
{
CString strVal="5.5";
DWORD retVal = {some how convert the strVal into an integer or DWORD};
return retVal
}
|
|
|
|
|
Use _ttol() to convert a CString to an int .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I'm trying to convert a "CString" not a "string"
dont' have to use a member fucntion on this object?
I thought I need to format it first?
|
|
|
|
|
CString strFoo = "1234";
int nFoo = _ttol (strFoo);
ASSERT (nFoo == 1234);
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Very Simple
Convert CString to String and then to int/double(whatever)
DWORD myfunc()
{
CString strVal="5.5";
char *str;
str=new char[CString.GetLength()+1];
for(int i=0;i<CString.GetLength();i++)
{
str[i]=CString.GetAt(i);
}
str[i]='\0';
return atol(str);
return atof(str);
}
I hope this solves ur problem.
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
it may work but very inefficient.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
Hi all,
I'm writing a simple dialog with a listbox in "report" mode. My problem is that in order for a user to select an item in the list, (s)he has to click on the 1st column in the list. Also, this will only highlight the first column and not the rest of the row. This is functional ofcourse but it would be nice the have the whole row highlited.
Any help would be greatly appreciated
Mark
|
|
|
|
|
DWORD dwStyle = ListView_GetExtendedListViewStyle (m_myListCtrl.GetSafeHwnd());
dwStyle |= LVS_EX_FULLROWSELECT;
ListView_SetExtendedListViewStyle (m_myListCtrl.GetSafeHwnd(), dwStyle);
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Need help...
How can I make a CMonthCalCtrl created at runtime (with Create(..)) not clipped by the parent window?
I need to show a CMonthCalCtrl control, and need to show it outside the bounds of a CFrameWnd, but when I create and show it in a view, this is clipped by the parent.
I tried with SetWindowPos(&wndTopMost...) but nothing..
Can anyone help me?
Thanks, Paolo
|
|
|
|
|
There is one thing you should know before using the advanced controls like Date-time-picker in ur program.
You should Call this function when your program starts.(You have to do this in API programming, cant say for sure about MFC, just give it a try. Refer www.msdn.com[^] for detailed info)
BOOL InitCommonControlsEx(<br />
LPINITCOMMONCONTROLSEX lpInitCtrls<br />
);
It registers specific common control classes from the common control dynamic-link library (DLL).
Parameters
lpInitCtrls
Address of an INITCOMMONCONTROLSEX structure that contains information specifying which control classes will be registered.
Return Values
Returns TRUE if successful, or FALSE otherwise
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
For some reason every time I call ShowWindow it just hangs and I never get control of my application back. This didn't happen just earlier today, I may have changed something, but I have it called in two places. I know that one of them (the first example) didn't get changed, so I know that it can't be what I changed.
Here is the code that (I have changed) calls ShowWindow:
bool BuildWindow()
{
const LPCSTR pstrTitle = "Game";
const LPCSTR pstrCaption = "Game";
WNDCLASS pwdcWndSpec =
{
CS_HREDRAW | CS_VREDRAW,
WindowProc,
0,
0,
GetModuleHandle(NULL),
NULL,
NULL,
NULL,
NULL,
pstrTitle
};
if ( !RegisterClass( &pwdcWndSpec ) )
{
Console::WriteLine("Error: Unable to register window.");
return false;
}
mhwdWndHandle = CreateWindowEx(
WS_EX_TOPMOST,
pstrTitle,
pstrCaption,
WS_POPUP,
0,
0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
NULL,
NULL,
pwdcWndSpec.hInstance,
NULL );
if ( !mhwdWndHandle )
{
Console::WriteLine("Error: Unable to create window.");
return false;
}
mhinWndInstance = pwdcWndSpec.hInstance;
ShowWindow( mhwdWndHandle, SW_SHOWNORMAL );
UpdateWindow( mhwdWndHandle );
SetFocus( mhwdWndHandle );
return true;
}
mhwdWndHandle - Global HWND
mhinWndInstance - Global hInstance
The other place I have it called is in a class I made to give better control of the console window (I have not changed):
void AdvancedConsole::SetWndState( enuWndState venuWndState )
{
ShowWindow( mhwdWndHandle, venuWndState );
}
mhwdWndHandle - Class level HWND
enuWndState - Enumeration:
__value enum enuWndState
{
wsHidden = SW_HIDE,
wsMax = SW_SHOWMAXIMIZED,
wsMin = SW_SHOWMINIMIZED,
wsNormal = SW_SHOWNORMAL
};
Any help would be greatly appreciated.
|
|
|
|
|
Just out of curiousity are you doing anything in OnPaint event that would hang for certain inputs?
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
I am not doing anything with on paint. This is my window's call back function though:
LRESULT CALLBACK WindowProc( HWND vhwdWndHandle, UINT vuntMsg, WPARAM vwprParam, LPARAM vlprParam )
{
Console::WriteLine("Handle message: {0}", Convert::ToString(vuntMsg));
switch ( vuntMsg )
{
case WM_KEYDOWN:
if( vwprParam == VK_ESCAPE )
{
PostQuitMessage( 0 );
return 0;
}
break;
case WM_DESTROY:
Console::WriteLine("Main window closed.");
PostQuitMessage( 0 );
return 0;
}
return DefWindowProc( vhwdWndHandle, vuntMsg, vwprParam, vlprParam );
}
I have found out that if I use a minimize action (SW_MINIMIZE, SW_SHOWMINIMIZED, or SW_SHOWMINNOACTIVE) with ShowWindow I don't have the hanging problem.
Thanks for the fast reply.
|
|
|
|
|
By looking at what the console displays after I end the process that contains the hanging ShowWindow, I find that window is trying to process the following messages non-stop:
WM_SETCURSOR
WM_NCHITTEST
Hopefully this will be of some more help.
|
|
|
|
|
can you comment this line.
Console::WriteLine("Handle message: {0}", Convert::ToString(vuntMsg));
and check wheather it works or not... otherwize there seems to be no problem.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
I just added that line to see what messages were being sent. It was doing that before I put the line in. I am new to windows programming so right now I am lost as far as this problem is concerned. I am going to try and handle the messages that it keeps passing and see if that helps. If it doesn't I don't know what I'll do.
Thanks for your help none-the-less
|
|
|
|
|
Okay, I've been struggling with this problem for the best part of a week now. If I don't find a solution soon, my PC's going for a flying lesson
I'm developing an MFC app, in VC++ 6.0 with the latest service patch applied, running on Windows NT. The program works fine in debug mode, but dies a horrible death in debug mode. "The instruction at "0x00918ec3" referenced memory at "0x00002301". The memory could not be "written".
Here's what I've tried so far...
1) Message boxes to try and pinpoint where the crash is occurring. After a bit of trial and error, the crash appears to occur sometime after a call in the application part of the code 'MyApp.cpp' : 'if (!ProcessShellCommand(cmdInfo))'. The crash occurs after this call is made, but before it returns. The last part of my own code that is called (as far as I can tell) is 'OnInitialUpdate' which is within the view. Now as far as I can see, it looks like the crash isn't happening in any of my code. No doubt it's somthing I've done, I just can't see where I did it!
2) Having drawn a blank with my usual method of release-mode debugging, I turned to google. I've read most of the debugging tutorials here on codeproject now and thought this might herald an answer, but the crash address doesn't appear to be relevent to either the program itself or any of the .dlls it loads (I used dependancy walker to have a look at what it uses). Their base addresses seem to be in the range 0x5F400000 (MFC42.dll) to 0x780C0000 (MSVCP60.dll) - nowhere near "0x00918ec3"!
Have I missed / mis-understood anything obvious? What should I try next?
I'd appreciate any suggestions you may have - thanks very much in advance!
Success is 99% failure
|
|
|
|
|
Almost certainly you are overwriting the stack somewhere before you call ProcessShellCommand. If you can't find the mistake by inspection (get someone else's eyes on it) and you don't want to invest in something like BoundsChecker or Purify, you might try a technique I've used in similar situations: Comment out suspect code until the crash goes away, then uncomment some until the crash comes back, and use a binary search to narrow down onto your mistake.
|
|
|
|