|
OK, that seems to explain it all. Thanks.
|
|
|
|
|
GetFileAttributes() is used to retrieve a set of FAT-style attributes. See if GetFileAttributesEx() behaves any differently.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi David, thanks for your suggestion.
GetFileAttributesEx() won't help me. I had problems understanding why ::FindFirstFile and GetFileAttributes() report different set of file attributes on FAT32.
And now I get it, TEMP files are not flushed to HDD, and therefore limitations of FAT can be see with ::FindFirstFile and not with GetFileAttributes().
I made a small test in which I created a file on USB stick (with FAT32 file system), then added a TEMP attribute to it and:
a) read file attributes right after creating file
b) then I safely removed USB drive (forcing windows to flush file to FAT)
c) re-read file attributes, now both ::FindFirstFile and GetFileAttributes() reported correct values
Now I can safely continue developing my enumeration class.
One more time, a BIG thank you to all three of you for your help, suggestions and explanations.
Best regards
loreia
|
|
|
|
|
the same way as with a button? There is a static control in my dialog, and if it is clicked (single click) an action must be performed.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
modified on Saturday, January 10, 2009 1:32 PM
|
|
|
|
|
The CStatic should have the BS_NOTIFY SS_NOTIFY style. If you are using MS Visual Studio then you can set this property in the dialog resource editor by setting the 'Notify' property to TRUE.
Some documentation:
STN_CLICKED Notification[^]
Best Wishes,
-David Delaune
[Edit]
Updated erroneous style.
|
|
|
|
|
Hi,
I tried what they said in MSDN:
The STN_CLICKED notification message is sent when the user clicks a static control that has the SS_NOTIFY style. The parent window of the control receives this notification message through the WM_COMMAND message.
I put SS_NOTIFY and BS_NOTIFY style on the static, but no WM_COMMAND was received when I clicked on it
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
BS_NOTIFY is for buttons, not statics, don't use it on a static, use only SS_NOTIFY. And you won't receive a command message you can handle using ON_COMMAND, you need to use ON_NOTIFY, specifying the ID (make sure this is not the default IDC_STATIC but something else, at least to avoid confusement) of your static and STN_CLICKED, or i think there should be an ON_STN_CLICKED macro somewhere too.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
sashoalm wrote: I put SS_NOTIFY and BS_NOTIFY style on the static
Sorry about that, I meant to say SS_NOTIFY. You also should change the ID of the CStatic to something other than the default. In your message map add:
ON_STN_CLICKED(IDC_STATIC_YOURNAME, &CYourClass::OnStnClickedStatic)
And in your header:
afx_msg void OnStnClickedStatic();
Best Wishes,
-David Delaune
|
|
|
|
|
Could there be something wrong with my static control? It's not working, and I checked that the id is not the default IDC_STATIC.
Here's how the static is defined in the *.rc2 file
LTEXT "Static",IDC_MY_STATIC_ID,81,198,109,8,
SS_CENTERIMAGE, SS_NOTIFY
I turned on the message loop tracing with MFC Tracer, but the only WM_LBUTTONUP and WM_LBUTTONDOWN messages were appearing when I was clicking on the static:
WndProc: hwnd=0x5B0BBA, msg = WM_LBUTTONDOWN (0x0001, 0x015700D0)
WndProc: hwnd=0x5B0BBA, msg = 0x036A (0x0000, 0x00000000)
WndProc: hwnd=0x5B0BBA, msg = 0x036A (0x0000, 0x00000001)
WndProc: hwnd=0x5B0BBA, msg = 0x036A (0x0000, 0x00000002)
WndProc: hwnd=0x5B0BBA, msg = 0x036A (0x0000, 0x00000003)
WndProc: hwnd=0x5B0BBA, msg = WM_LBUTTONUP (0x0000, 0x015700D0)
WndProc: hwnd=0x5B0BBA, msg = 0x036A (0x0000, 0x00000000)
WndProc: hwnd=0x5B0BBA, msg = 0x036A (0x0000, 0x00000001)
WndProc: hwnd=0x5B0BBA, msg = 0x036A (0x0000, 0x00000002)
WndProc: hwnd=0x5B0BBA, msg = 0x036A (0x0000, 0x00000003)
[Added]
I checked again and the hwnd is actually that of the dialog! The static control didn't receive any event in the first place.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
modified on Saturday, January 10, 2009 1:28 PM
|
|
|
|
|
I found where the problem is, I had incorrectly written the flags. The dialog was in a *.rc2 file so it had to be edited manually.
Thanks, your solution works now
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Glad you have located the problem, I was beginning to scratch my beard with absolute dismay.
Best Wishes,
-David Delaune
|
|
|
|
|
Be careful that you have to change the default id of static - IDC_STATIC to something else like IDC_STATIC_MY_LABEL. Or else the static will not notify any messages.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
|
When i applied LAYOUTRTL layout on my window by setting extended window style, everthing went fine. All the contorls, title bar, scroll bar all are now in right to left layout. However the images that were being displayed previously are not being displayed instead of that blank window is being displayed in place of the image data.
I am now totally clueless.
|
|
|
|
|
Hello to all,
First of all let me tell you what I am doing in my project, in my project I am collecting some data from two devices, one device is having USB connector and another device is having serial port (RS232) connector.
Now I will tell you the main problem, In my project I am creating one file and writting the data collected from any one of above device, into that file.The function in which I have written file writting operation code gets called after each 10 seconds. But problem is that when I collect data from device having serial port (RS232) connector then sometimes I get "CFile::sharingViolation" exception in file operation.I am giving my code also here. In below code "CreateRawDataFile()" function gets called after each 10 seconds and this function contains the code regarding file handling operation.
void CMainFrame::CreateRawDataFile()
{
CFile oRawFile;
CFileException ExceptionObj;
if(oRawFileIO.Open(FileName,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite,&ExceptionObj)==FALSE)
{
if(ExceptionObj.m_cause == CFileException::sharingViolation)
{
TRACE("\n Sharing violation");
}
}
else
{
code for writting data in a file
.
.
.
.
oRawFile.Close();
}
}
In above function sometimes I get "CFileException::sharingViolation" exception and then the TRACE statement which I have written gets displayed.Most surprising thing is that this file exception occurs only when I collect the data from the device having serial port (RS232) connector.Also I have checked that call to above function is going exactly after each 10 seconds and not before that.Also data is not much long which will not get written into file within 10 seconds.Most surprisingly it works very much accuratly without any file exception when I collect data from the device having USB connector.
Really I am not getting what exactly happening? Please can any body tell me what to do and how to remove this problem? It is really really very very urgent? Please help me out.
Thanks and Regards,
Anay
|
|
|
|
|
Maybe you have a race condition, where the USB handler has opened the file and then the serial handler tries to open it as well?
If I were you, I hold the file open through the life of the program (make the CFile variable a member of CMainFrame and open it in CMainFrame::Create , close it when the CMainFrame closes). Then there's no worry about the file needing to be shareable, as you won't be trying to open it more than once.
|
|
|
|
|
I build a web browser using Chtmlview.
and now I don't want use "Navigate2" function ,I want to get HTTP request ,which is come from the web browser, and store the this HTTP request,send it to WEB server by myself.
at the other hand , I can acquire the HTTP response by my application , How can I send the response to the web browser built by Chtmlview class.
I mean that how can I send/get the HTTP message between the chtmlview and myself.
Thank you very much!
Lampa
|
|
|
|
|
If you have the HTTP response, extract the body into a string and set it as the CHtmlView 's document by extracting the web browser interface pointer with CHtmlView::GetHtmlDocument and using the sample code on this page[^].
|
|
|
|
|
Hello Stuart Dootson:
Thank you for your reply.
Could you tell me how to get the HTTP request from the web browser ,which built by CHtmlView?
That is , when I click the button (or super HTTP link ),and the CHtmlView will generate the HTTP request and send it to WEB server . I want to get the HTTP request, how to do it?
Where can I find the answer?
Thank you again !
Lampa
|
|
|
|
|
maoxintt wrote: Could you tell me how to get the HTTP request from the web browser
Ah, sorry - thought you'd already done that bit...Anyway, you probably want to use the CHttpFile class in MFC. If you look at this page, Microsoft list the exact steps you need to take to read data over HTTP. Doesn't get better than that!
|
|
|
|
|
Thank you for your reply!
I am a newer for MFC. I have built a web browser using CHtmlView ,and I want to how to get the HTTP request from the web browser using ChtmlView.
I don't familiar with MFC , so could you tell me more about how to get it. I think the CHttpFile is use to handle the response from the WEB server. And I need to do is that how to intercept the HTTP request generated by my web browser.
Lampa
|
|
|
|
|
I dont know how to explain this.
I have a Visual Basic project which i wrote it for long time.
Now,I want control VB project from VC++ project.
For Example:
There is a "A" Button, and Text in CString of VC++ project (MFC exe).
when "A" button is pressed.
It will act like "B" button in VB project and Text will show on VB dialog.
I have heard the visual studio has tool for this but i can not find how does it look like..
Looking forward for your advice .
Thank
M
|
|
|
|
|
Member 4626568 wrote: I dont know how to explain this.
That's a bad start...
Member 4626568 wrote: There is a "A" Button, and Text in CString of VC++ project (MFC exe).
when "A" button is pressed.
It will act like "B" button in VB project and Text will show on VB dialog.
So...the VB and VC++ applications are both running and you want to control aspects of the VB app from the VC++ app? Tricky...
Member 4626568 wrote: I have heard the visual studio has tool for this but i can not find how does it look like.
Nope, can't say as it does.
|
|
|
|
|
I dont understand what do you need do you want to convert your code or you want to use of a project on other project?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I have a list control in my View class, (i created a list control using on draw )which I can see it on my main frame. But it does not show up in the print preview. Any help would be appreciated.
|
|
|
|