|
Look up DrawFocusRect() in the online doc.
|
|
|
|
|
Search code project for paint type programs (there is more than one).
Trust in the code Luke. Yea right!
|
|
|
|
|
CRectTracker !!!
CRectTracker !!!
CRectTracker !!!
|
|
|
|
|
I have an unusual problem, which I hope some of you can help with.
I have an application which uses a CFileDialog to ask the user for a file path. Nothing unusual in that. Should be straightforward. The CFileDialog is only ever called in the user interface thread.
On most computers the code works fine. It simply calls the constructor with appropriate arguments and calls DoModal(). On some computers the code works fine most of the time and then occasionally bombs out. It doesn't appear to matter if the various parameters are set to definite values, or to the defaults (this has been tested, it is not a guess).
I cannot reproduce the problem and hence it is hard for me to diagnose, other than the information above.
I've tried looking on the web, microsoft and all the usual places and can't find any reference to this problem at all.
Has anyone come across this problem before, and do they know how to fix it?
VC++ 6.0, dynamically linked to MFC. Target: NT/2000/XP.
Cheers
Stephen
(posting anonymous as this machine has never seen me before (no cookie) and I can't remember my PW).
|
|
|
|
|
Anonymous wrote:
The CFileDialog is only ever called in the user interface thread.
Can we infer that this is a multi-threaded application?
|
|
|
|
|
DavidCrow wrote:
Anonymous wrote:
The CFileDialog is only ever called in the user interface thread.
Can we infer that this is a multi-threaded application?
Yes. Sorry I should have been more explicit.
|
|
|
|
|
The first thing I'd try is to "remove" all but the primary thread, unless CFileDialog relies upon the existence of another thread. Since the problem is intermittent, I wouldn't dismiss the possibility of the primary thread "butting heads" with some other thread. Were that the case, I would expect the program to just crash rather than simply not display a dialog box.
|
|
|
|
|
<small><b>DavidCrow wrote:</b></small>
<i>The first thing I'd try is to "remove" all but the primary thread, unless CFileDialog relies upon the existence of another thread.</i>
Not an option I'm afraid. Without the other threads, you'll never get to the point where you can click to get the CFileDialog.
<i> Since the problem is intermittent, I wouldn't dismiss the possibility of the primary thread "butting heads" with some other thread. Were that the case, I would expect the program to just crash rather than simply not display a dialog box. </i>
So would I.
|
|
|
|
|
I have the same problem with CFileDialog myself.
It crashes on the destructor of the CFileDialog...
It only happens in a file where I use MS-Word Automation (if that helps someone).
Appreceate any help on this.
Amihai
|
|
|
|
|
Amihai wrote:
I have the same problem with CFileDialog myself.
It crashes on the destructor of the CFileDialog...
It only happens in a file where I use MS-Word Automation (if that helps someone).
The crash I am seeing is somewhere inside OLEAUT32.dll (I think). The code never manages to display the CFileDialog,
let alone reach the destructor.
Stephen
|
|
|
|
|
Anonymous wrote:
The crash I am seeing is somewhere inside OLEAUT32.dll (I think). The code never manages to display the CFileDialog,
Ahem, never type from memory. The crash is inside OLE32.DLL. Note that there is no reference to my application in the callstack. This is a sample crash callstack from the customer that has the problem (some of
the time).
000149ee()
ole32.dll!OleRun() + 0x2d1f
ole32.dll!CoGetTreatAsClass() + 0x7c8
ole32.dll!OleRun() + 0x2782
ole32.dll!CoGetTreatAsClass() + 0x8a7
ole32.dll!CoGetTreatAsClass() + 0x69f
ole32.dll!CoGetTreatAsClass() + 0x238
ole32.dll!CoGetTreatAsClass() + 0x1f8
ole32.dll!CoGetTreatAsClass() + 0x6f8
ole32.dll!OleRun() + 0x2782
ole32.dll!OleRun() + 0x2814
ole32.dll!OleRun() + 0x2782
ole32.dll!OleRun() + 0x2966
ole32.dll!CoCreateInstanceEx() + 0x46
ole32.dll!CoCreateInstanceEx() + 0x1c
ole32.dll!CoCreateInstance() + 0x32
shlwapi.dll!StrToIntW() + 0x200
shell32.dll!SHCLSIDFromString() + 0x4c5
shell32.dll!SHCoCreateInstance() + 0x33
shell32.dll!DllGetVersion() + 0x1ce0
shell32.dll!SHGetIconOverlayIndexA() + 0x379
shell32.dll!SHCLSIDFromString() + 0x1a1
shell32.dll!SHCLSIDFromString() + 0x1cd
shell32.dll!SHCoCreateInstance() + 0x33
shell32.dll!SHMultiFileProperties() + 0x8ad
shell32.dll!SHLoadNonloadedIconOverlayIdentifiers() + 0x1838
shell32.dll!DriveType() + 0x2d65
shell32.dll!Shell_GetImageLists() + 0xf
user32.dll!SetWindowPlacement() + 0x57
user32.dll!DefRawInputProc() + 0x3eb
user32.dll!CharPrevW() + 0x3c8
user32.dll!DefDlgProcW() + 0x21
user32.dll!DefRawInputProc() + 0x284
user32.dll!ScreenToClient() + 0xd7
user32.dll!CallWindowProcW() + 0x19
> mfc42u.dll!_AfxActivationWndProc(HWND__ * hWnd=0x003b1acc, unsigned
int nMsg=44, unsigned int wParam=1137, long lParam=449444) Line 428 + 0x13
C++
user32.dll!SetWindowPlacement() + 0x57
user32.dll!DefRawInputProc() + 0x284
user32.dll!IsWindowVisible() + 0x770
user32.dll!SendMessageW() + 0x44
user32.dll!SetParent() + 0x29e
user32.dll!DlgDirSelectComboBoxExA() + 0x19a
user32.dll!GetWindowLongW() + 0x268
user32.dll!SetScrollPos() + 0xb52
ntdll.dll!KiUserCallbackDispatcher() + 0x13
user32.dll!CharPrevW() + 0x13cf
user32.dll!CheckRadioButton() + 0x10b
user32.dll!DialogBoxIndirectParamAorW() + 0x35
user32.dll!DialogBoxIndirectParamW() + 0x19
comdlg32.dll!GetOpenFileNameA() + 0x21c
comdlg32.dll!GetOpenFileNameA() + 0x27
[this is where my app calls from]
Stephen
|
|
|
|
|
Hi,
How do i write a program that evaluate the length of a vector?
Because i have this piece of code and when i complie it i get plenty of errors
#include <stdio.h>
#include <math.h>
double tailing = 0;
double trl_values = 0;
double y_int_1 = 0;
int rest = 0;
double leading = 0;
double histogram_ram = 0;
double i_index;
double Trl_values;
double y_int = 0;
/*******************************************************************************************
Transfer function:
1
----------------
3.333e-005 s + 1
Transfer function:
0.1829 z + 0.11829
-----------------------
z - 0.6341
Sampling time: 1.9113e-008
********************************************************************************************/
unsigned char Slice_level(unsigned char x) // Function accessible only from this file
{
double b0=0.1829,b1=0.11829;
double a1= 0.6341;
double temp_x1,temp_x2;
double temp_y1;
unsigned char y;
int static xn_1;
int static yn_1,yn_2; // y(n-1)
temp_x1 = x * b0;
temp_x2 = xn_1* b1;
temp_y1 = yn_1 * a1;
y = temp_x1+ temp_x2 + temp_y1;
xn_1 = x;
yn_1 = y;
return y;
}
//main()
void SLFilter (long amount, unsigned char* pData)
{
long n;
unsigned char y;
for (n=0; n<amount; n++)
="" {
="" y="Slice_level(pData[n]);
" pdata[n]="y;
"
="" printf("%8d="" n",y);
="" }
}
="" *******************************************************************************************
="" this="" code="" shows="" the="" trl_values="" calculation.="" it="" is="" going="" to="" help="" determining="" histogram=""
********************************************************************************************=""
void="" trl_calculation(int="" amount,="" unsigned="" char*pdata)
{
="" long="" n;
="" for="" (int="" i="1;" <="amount;" i++)
="" if="" ((y_int_1)="" -="" 0)="" &="" (y_int=""> 0)
tailing = 1 - (y_int- pData[n])/(y_int - y_int_1);
Trl_values(length(Trl_values)+1) = tailing + leading + rest;
leading = 1 - tailing;
rest = 0;
if ((y_int_1- pData[n] > 0)&(y_int- pData[n] < 0))
tailing = 1 - (y_int - pData[n])/(y_int - y_int_1);
Trl_values(length(Trl_values)+1) = tailing + leading + rest;
leading = 1 - tailing;
rest = 0;
rest = rest + 1;
y_int_1 = y_int;
}
}
void histogram(int amount, unsigned char*pData)
{
const double Duration = amount/4096;
for (int i=1; i <= amount; i++)
{
i_index = ceil(Trl_values(i)/Duration)+1;
histogram_ram(i_index)=histogram_ram(i_index)+1;
}
}
It looks like i am mixing up functions and variables.
May be i should create sub programs to carry out the task?
help with this code plz.
I provide the matlab code i want to translate into C as well
function trl_calculation
Trl_values = 0;
y_int_1 = 0;
rest = 0;
leading = 0;
Dura=10000/4096;%x ns per byte=total 1000ns / 4096 bytes.
read_data10
sl= 53.9998;
%lpfmodel_1st
%sl=lpfmodel_1st(t,y);
%sl=sl(k);
for i = 1:length(y)
y_int = y(i);
% Trl_function;
if ((y_int_1-sl<0)&(y_int-sl>0))
tailing = 1 - (y_int-sl)/(y_int-y_int_1);
Trl_values(length(Trl_values)+1) = tailing + leading + rest;
leading = 1 - tailing;
rest = 0;
else if ((y_int_1-sl>0)&(y_int-sl<0))
tailing = 1 - (y_int-sl)/(y_int-y_int_1);
Trl_values(length(Trl_values)+1) = tailing + leading + rest;
leading = 1 - tailing;
rest = 0;
else
rest = rest + 1;
end;
end;
% As mentioned above, for example, y_int_1 is initial sample;
% y_int is next sample.
y_int_1 = y_int;
tailing
leading
rest
end;
histogram_ram(1:4096) = 0;
for i=1:length(Trl_values)
i_index=round(Trl_values(i)/Dura)+1;
histogram_ram(i_index)=histogram_ram(i_index)+1;
end;
plot(histogram_ram)
hx
F.K
|
|
|
|
|
|
how do you find your way around MSDN so easily!
It took me hours to find documentation on all the CListCtrl crap!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Nitron wrote:
how do you find your way around MSDN so easily!
I already knew the proper function and Google and I became friends a while back.
-Nick Parker
|
|
|
|
|
Hi, everyone!
When using the following piece of codes to get the hour value of
the day, I find the value I can get is always 8 hours lower than current time.
I do not know why. Can anyone help?
--------
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
time_t curr_time;
time (&curr_time);
struct tm *curr_tm=gmtime (&curr_time);
cout << curr_tm->tm_hour << endl; //not correct
cout << (curr_tm->tm_hour + 8) % 24 << endl; //not correct
return 1;
}
--------
Thanks in advance,
George
|
|
|
|
|
Is your TZ set correctly?
|
|
|
|
|
Thanks, DavidCrow buddy!
How to check the setup of Time Zone?
I am not in U.S.
regards,
George
|
|
|
|
|
Right-click on the time in the icon tray and select Adjust Date/Time. Click on the Time Zone tab. Yours is probably correct since localtime() is working for you.
|
|
|
|
|
Thanks, DavidCrow buddy!
I want to know if I use gmtime to get GMT time,
how can I correctly change it to correct localtime?
Are there some sample codes I can make a reference?
regards,
George
|
|
|
|
|
Change gmtime to localtime
jhaga
CodeProject House, Paul Watson wrote:
...and the roar of John Simmons own personal Nascar in the garage. Meg flitting about taking photos.Chris having an heated arguement with Colin Davies and .S.Rod. over egian values. Nish manically typing *censur*. Duncan racing around after his pet *c.* Michael Martin and Bryce loudly yelling *c.* C.G. having a fit as Roger Wright loads up *c.* . Anna waving her *c.* and Deb scoffing chocolates in the corner.
...Good heavens!
|
|
|
|
|
Thanks, jhaga buddy!
Your method works perfect. But why gmtime is wrong?
regards,
George
|
|
|
|
|
gmtime gives Greenwich Mean Time and your timezone is
8 hours off that.
jhaga
CodeProject House, Paul Watson wrote:
...and the roar of John Simmons own personal Nascar in the garage. Meg flitting about taking photos.Chris having an heated arguement with Colin Davies and .S.Rod. over egian values. Nish manically typing *censur*. Duncan racing around after his pet *c.* Michael Martin and Bryce loudly yelling *c.* C.G. having a fit as Roger Wright loads up *c.* . Anna waving her *c.* and Deb scoffing chocolates in the corner.
...Good heavens!
|
|
|
|
|
Thanks, jhaga buddy!
I want to know if I use gmtime to get GMT time,
how can I correctly change it to correct localtime?
Are there some sample codes I can make a reference?
regards,
George
|
|
|
|
|
Since they both operate on the value returned from time(), why not just pass that same value to localtime()? Something like:
struct tm *tm1, *tm2;<br />
time_t _time;<br />
<br />
time(&_time );<br />
tm1 = gmtime(&_time); <br />
tm2 = localtime(&_time);
|
|
|
|