|
Thanks, it was a helpful article indeed. But having come across the debug Vs release problems before, this one baffles me a little, cuz both the versions are in debug mode!
Its like the results differ when i step thru the method, and when i directly execute the method. The latter being a correct result.
------------------------------------
Vision is the ability to see the invisible
|
|
|
|
|
Adding/repeating the article linked:
Race condition is the most likely, if your code includes a chance for that.
Second-highest chance goes to uninitialized variables or using uninitialized pointers, the change caused by different memory initializations.
Be more specific: what does "does not work" mean?
|
|
|
|
|
peterchen wrote: Race condition is the most likely, if your code includes a chance for that
No chance for a Race condition.
As for the precise problem, well the results differ when I step thru the method and when i directly execute the method.
Correct result being LB_SETCURSEL working with SendDlgItemMessage().
the application is built in the debug mode, so no question of a debug vs release problem.
Uninitialized variables went thru my lil mind too, but why wud it not fail when i "Ctrl+F5" the application, and work when i just "F5" the app??
------------------------------------
Vision is the ability to see the invisible
|
|
|
|
|
You are working at different memory locations depending on running under the debugger or as standalone (even ctrl+F5 vs. double-clicking the exe can show differences...). Normally, in debug builds, memory locations are initilized to the same value, but there are loopholes.
Did you check the return value of SendDlgItemMessage?
Also, there are some patterns to avoid or use when sending messages, especially when focus involved, e.g. changing focus during a focus change message never works correctly.
When running under the debugger step by step, your application will get (and handle) additional killfocus and setfocus messages. Which might at least explain the difference.
|
|
|
|
|
Ah VC6...
The compiler is buggy, so if you've tweaked any of the compiler knobs first untweak them. The defaults are the safest & most reliable.
Next, do a full rebuild regardless. Out of sync object files create a variety of mysterious problems.
Assuming a clean build, you might be getting an exception that's masked by the breakpoint trap. I'd probably brute force debug this by just adding TRACE statements to narrow down where the error occurs.
-- Ian
|
|
|
|
|
Hi,
I have an application that has a ListCtrl. After creating a new dialog over the ListCtrl, and if I close the dialog by Cancel or OK button, there is a shadow that has the Windows dialog classic color covering some part of the ListCtrl. For columns on the ListCtrl, I can just put the cursor over it and then the text is shown automatically. For Items, I have to Left click them to get them displayed.
Also, if I minimize the application and restore it again, the whole part of the ListCtrl is covered by the windows classic color.
My system is Windows XP in Classic theme.
Thanks for any idea or help about this.
Toe the line
Thread the needle
Think outside of the box
|
|
|
|
|
It sounds like you've sent WM_SETREDRAW to your listctrl at some point. (probably using an MFC function), and didn't clear it.
Iain.
|
|
|
|
|
hello , i've tryed to capture snapshots on yahoo webcam with bitblt to make a yahoo webcam recorder, i managed to do it but with some problems. on my webcam it works perfectly the image captured is clear but if i try to snapshot another webcam window(some work some don't) the image is scrambled. i will post the entire source code it's not too long and a sample snapshot to see the problem.
http://rapidshare.com/files/73346892/frame_2.bmp.html
<br />
HWND frame,mainwin,last=NULL;<br />
<br />
<br />
bool writebmpfile(int bitmap_dx,int bitmap_dy,int bytes, BYTE *memory,BITMAPFILEHEADER fileHeader,BITMAPINFOHEADER infoHeader,int frame);<br />
<br />
<br />
typedef struct cadre<br />
{<br />
char cadru[200];<br />
}cadre;<br />
<br />
<br />
cadre cadre[10000];<br />
<br />
<br />
<br />
BOOL CALLBACK findchildweb(HWND hwnd,LPARAM lParam)<br />
{<br />
char clasa[100]={0};<br />
char text[150]={0};<br />
<br />
<br />
GetClassName(hwnd,clasa,100);<br />
<br />
if(!strcmp(clasa,"ATL:0B39D378")|| !strcmp(clasa,"#32770"))<br />
{ <br />
frame=hwnd;<br />
<br />
<br />
}<br />
<br />
GetWindowText(hwnd,text,150);<br />
<br />
if(strstr(text,"Last")!=NULL || strstr(text,"Broadcast")!=NULL)<br />
{<br />
last=hwnd;<br />
<br />
}<br />
<br />
<br />
<br />
<br />
if(last!=NULL && frame!=NULL)<br />
return false;<br />
else<br />
return true;<br />
<br />
}<br />
<br />
<br />
<br />
BOOL CALLBACK findwebwnd(HWND hwnd,LPARAM lParam)<br />
{<br />
char clasa[100]={0};<br />
<br />
GetClassName(hwnd,clasa,100);<br />
<br />
if(!strcmp(clasa,"WebcamClass"))<br />
{<br />
mainwin=hwnd;<br />
EnumChildWindows(hwnd,findchildweb,0);<br />
return false;<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
return true;<br />
}<br />
<br />
<br />
<br />
<br />
bool findandcapture()<br />
{<br />
frame=NULL;<br />
HDC devcnt=NULL,devc=NULL,cmpdc=NULL;<br />
RECT dim={0};<br />
HBITMAP bmp=NULL;<br />
BYTE *memory=0;<br />
<br />
BITMAPFILEHEADER fileHeader;<br />
BITMAPINFOHEADER infoHeader;<br />
BITMAPINFO info;<br />
int numframe=-1;<br />
<br />
char cur[150]={0},prev[150]={0};<br />
<br />
<br />
<br />
<br />
<br />
<br />
EnumWindows(findwebwnd,0);<br />
<br />
<br />
<br />
<br />
if(frame!=NULL)<br />
devcnt=GetWindowDC(frame);<br />
else<br />
return false;<br />
<br />
GetWindowRect(frame,&dim);<br />
<br />
int bitmap_dx = dim.right - dim.left;<br />
int bitmap_dy = dim.bottom - dim.top;<br />
<br />
fileHeader.bfType = 0x4d42;<br />
fileHeader.bfSize = 0;<br />
fileHeader.bfReserved1 = 0;<br />
fileHeader.bfReserved2 = 0;<br />
fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);<br />
<br />
infoHeader.biSize = sizeof(infoHeader);<br />
infoHeader.biWidth = bitmap_dx;<br />
infoHeader.biHeight = bitmap_dy;<br />
infoHeader.biPlanes = 1;<br />
infoHeader.biBitCount = 24;<br />
infoHeader.biCompression = BI_RGB;<br />
infoHeader.biSizeImage = 0;<br />
infoHeader.biXPelsPerMeter = 0;<br />
infoHeader.biYPelsPerMeter = 0;<br />
infoHeader.biClrUsed = 0;<br />
infoHeader.biClrImportant = 0;<br />
info.bmiHeader = infoHeader;<br />
<br />
<br />
<br />
cmpdc=CreateCompatibleDC(devcnt);<br />
<br />
bmp=CreateDIBSection(devcnt, &info, DIB_RGB_COLORS, (void**)&memory, 0, 0);<br />
DWORD eror=GetLastError();<br />
SelectObject(cmpdc,bmp);<br />
<br />
<br />
<br />
while(1)<br />
{<br />
<br />
<br />
if(strcmp(cur,prev) || strstr(prev,"Broad")!=NULL)<br />
{<br />
numframe++;<br />
<br />
GetWindowText(last,cur,150);<br />
<br />
BitBlt(cmpdc, 0, 0, bitmap_dx, bitmap_dy, devcnt, 0, 0, SRCCOPY);<br />
<br />
int bytes = (((24*bitmap_dx + 31) & (~31))/8)*bitmap_dy;<br />
<br />
<br />
<br />
writebmpfile(bitmap_dx,bitmap_dy, bytes, memory,fileHeader,infoHeader,numframe);<br />
<br />
<br />
DeleteObject(bmp);<br />
<br />
if(UpdateWindow(mainwin)==false)<br />
break;<br />
<br />
if(strstr(prev,"Broad")!=NULL)<br />
Sleep(500);<br />
<br />
}<br />
else<br />
Sleep(1);<br />
<br />
<br />
GetWindowText(last,prev,150);<br />
<br />
<br />
<br />
<br />
Sleep(1);<br />
}<br />
<br />
<br />
<br />
<br />
DeleteDC(cmpdc);<br />
ReleaseDC(frame, devcnt);<br />
<br />
<br />
<br />
<br />
<br />
return true;<br />
}<br />
<br />
<br />
bool writebmpfile(int bitmap_dx,int bitmap_dy,int bytes, BYTE *memory,BITMAPFILEHEADER fileHeader,BITMAPINFOHEADER infoHeader,int frame)<br />
{<br />
<br />
<br />
<br />
<br />
FILE *fisier;<br />
<br />
<br />
sprintf(cadre[frame].cadru,"%s_%d.%s","frame",frame,"bmp");<br />
<br />
<br />
<br />
fisier=fopen(cadre[frame].cadru,"w+");<br />
<br />
<br />
<br />
fwrite((char*)&fileHeader,1,sizeof(fileHeader),fisier);<br />
<br />
fwrite((char*)&infoHeader,1,sizeof(infoHeader),fisier);<br />
<br />
fwrite(memory,1,bytes,fisier);<br />
<br />
<br />
<br />
fclose (fisier);<br />
<br />
<br />
<br />
<br />
return true;<br />
}<br />
<br />
<br />
<br />
|
|
|
|
|
What do you mean by "scrambled"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
the picture has interference like an old tv or a cracked LCD display
|
|
|
|
|
I don't have an old TV or a cracked LCD display to compare to.
Can you post an example image somewhere?
If it works on some windows and not others, then I imagine it's
a problem with the way the video is being rendered (DirectX,
for example), you're scraping the screen out of sync with the video
refresh, or you're getting frames in between key frames.
Just guesses...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
http://rapidshare.com/files/73346892/frame_2.bmp.html here is the sample image and i noticed that CreateDIBSection returns Not enough storage is available to process this command.
|
|
|
|
|
I couldn't see the image, but I've been trying to find something in the code.
Shouldn't the DeleteObject(bmp); call be outside/after the while() loop?
You should also select bmp out of the memory DC (by selecting its original bitmap back in)
before you delete it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Does this work (changes marked in color)?
bool findandcapture()
{
frame=NULL;
HDC devcnt=NULL,devc=NULL,cmpdc=NULL;
RECT dim={0};
HBITMAP bmp=NULL;
BYTE *memory=0;
BITMAPFILEHEADER fileHeader;
BITMAPINFOHEADER infoHeader;
BITMAPINFO info;
int numframe=-1;
char cur[150]={0},prev[150]={0};
EnumWindows(findwebwnd,0);
if(frame!=NULL)
devcnt=GetWindowDC(frame);
else
return false;
GetWindowRect(frame,&dim);
int bitmap_dx = dim.right - dim.left;
int bitmap_dy = dim.bottom - dim.top;
fileHeader.bfType = 0x4d42;
fileHeader.bfSize = 0;
fileHeader.bfReserved1 = 0;
fileHeader.bfReserved2 = 0;
fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
infoHeader.biSize = sizeof(infoHeader);
infoHeader.biWidth = bitmap_dx;
infoHeader.biHeight = bitmap_dy;
infoHeader.biPlanes = 1;
infoHeader.biBitCount = 24;
infoHeader.biCompression = BI_RGB;
infoHeader.biSizeImage = 0;
infoHeader.biXPelsPerMeter = 0;
infoHeader.biYPelsPerMeter = 0;
infoHeader.biClrUsed = 0;
infoHeader.biClrImportant = 0;
info.bmiHeader = infoHeader;
cmpdc=CreateCompatibleDC(devcnt);
bmp=CreateDIBSection(devcnt, &info, DIB_RGB_COLORS, (void**)&memory, 0, 0);
DWORD eror=GetLastError();
<font color="Red">HGDIOBJ hOldBMP = </font>SelectObject(cmpdc,bmp);
<font color="Green">
<font color="Red">int bytes = (((24*bitmap_dx + 31) & (~31))/8)*bitmap_dy;</font>
while(1)
{
if(strcmp(cur,prev) || strstr(prev,"Broad")!=NULL)
{
numframe++;
GetWindowText(last,cur,150);
BitBlt(cmpdc, 0, 0, bitmap_dx, bitmap_dy, devcnt, 0, 0, SRCCOPY);
<font color="Green">
<font color="Red">
writebmpfile(bitmap_dx,bitmap_dy, bytes, memory,fileHeader,infoHeader,numframe);
<font color="Green">
if(UpdateWindow(mainwin)==false)
break;
if(strstr(prev,"Broad")!=NULL)
Sleep(500);
}
else
Sleep(1);
GetWindowText(last,prev,150);
Sleep(1);
}
<font color="Red">SelectObject(cmpdc,hOldBMP);
DeleteObject(bmp);</font>
DeleteDC(cmpdc);
ReleaseDC(frame, devcnt);
return true;
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
nope same problem and getlasterror still returns Not enough storage after the CreateDIBsection func. i think there is the problem maybe i miscalculated something on the bitmap structures , what do you think ?
P.S : thanks for your kindness to help me
|
|
|
|
|
It looks ok to me - I'm not sure what I'm missing (obviously )
CreateDIBSection is returning NULL and then GetLastError() returns what?
The only thing that should affect that is the width and height - what are those values?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
width=324 and height=244 i get them from GetWindowRect(frame,&dim). if you would like to simplify our communication add my ymsg id : csman_ul
|
|
|
|
|
Hi
I have created Custom dll to override the Windows OS Dialler.
for that we need to make the appr. entry of our dll into rasphone.pbk
CustomRasDialDll=c:\,....\customDial.dll
Now problem is if I open windows mail it triggers the dll and which finally calls "RasCustomDialDlg" method,which connects through the internet using the RasDial API,
But after that i disconnect the conneciton and again try to open the Windows mail so it should again call my dll's RasCustomDialDlg
But it's not doing so intead it calls system dialler..that i want to avoid..
It seems after doing first time conneciton it changes some regsitry entry which causes this ? not sure
please advice. if u do not understnd let me know i can explain in brief..
thanks,
Prakash.
sonani prakash
|
|
|
|
|
Hello everyone,
There are 4 runtime library options, my understanding is,
1. /MT static link to CRT release version
2. /MTd static link to CRT debug version
3. /MD dynamic link to CR release version
4. /MDd dynamic link to CRT debug version
Is my understanding correct?
thanks in advance,
George
|
|
|
|
|
You simply missed that all options refer to multithreaded version of the run-time library.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I think the single threaded library is deprecated as of VS 2005 and not available. Unless I missed a hack somewhere
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I didn't know about.
Anyway is worth noting that the libraries are all multithreaded (even if you have no alternative).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
1. download a project rar, extract it into a directory
2. add to vss6, not through vc6, just open sourcesafe directly, and add the project's root directory to vss6 recursively
3. delete the project outside sourcesafe
When I want to get it out again, I tried both "Get Lastest Version" and "Check out", though the project is get out of vss6, but it seems not associated with vss6. How to let the project files be controlled under vss6?
PS: I leave the working fold by default when get or check out, and check off "Make writable".
|
|
|
|
|
followait wrote: ...but it seems not associated with vss6.
What exactly does this mean?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It means that when I want to edit the file, I need not check it out, and when I finished editing, I can't check it in.
|
|
|
|
|