|
I do a lot of work in VS2008. It's the editor I have to use for WEC 7 development. I must have 7 different device SDKs installed in my laptop. Recommendation - if you have to do multi-target development, I'd install each in their own VM. Anyway...
So I'm trying to fix some things in a source repository. Made a few changes and tried to save the cpp file. It tells me the fail is locked. okay, Save As... send it to src1.cpp.
Exit VS2008. Nope, there is a phantom dialog window open, I cannot leave. Well, FU VS2008, I kill off the process.
Go to the source folder, try to delete src.cpp. This is what I get:
"The action can't be completed because the file is open in Microsoft C/C++ Compiler Driver"
Now this is completely new to me.
Anyone else seen this error? I know how to ultimately make it go away, but I don't want to reboot just yet.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
I have never seen that message but had similar problems with older VS versions. You don't need to reboot when using the SysInternals Handle[^] or Process Explorer[^] utility to close the file handle.
Using Handle (for the command line purist)
Execute handle with the file name as parameter to get the handle and the process ID of the application that has opened it:
handle src.cpp
The output looks like this (98C is the handle as hex number):
<app>.exe pid: 2328 type: File 98C: <path>\src.cpp
Then execute handle again with the -c and -p options to close it:
handle -c 98C -p 2328
Using Process Explorer (for the friend of mice)
To close the handle using the ProcessExplorer, search for the file name (Ctrl+F or the Find menu), double click on the found item so that it is selected in the main window, right click on the item in the main window to open the context menu, and choose 'Close Handle'.
Warning
The usual disclaimer:
Close only files of processes that are no longer working (has been killed or exited upon critical errors)!
|
|
|
|
|
Wow, thanks for the tools. Very helpful.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
I am creating a CListBox manually as part of a auto-complete editbox (CEdit) to display possible choices.
The complete UI is something like:
CDialog
CMFCPropertyGridCtrl
Subclassed CMFCPropertyGridProperty to use my own CEdit Class, AutoCompleteEditBox (override CreateInPlaceEdit).
CEdit
CListBox
I create my listbox in the AutoCompleteEditBox:
void AutoCompleteEditBox::ShowListBox()
{
if ( !m_ListBox.GetSafeHwnd() )
{
UINT extendedStyle = WS_EX_CONTROLPARENT | WS_EX_TOOLWINDOW|WS_EX_WINDOWEDGE|WS_EX_TOPMOST;
UINT style = LBS_NOTIFY|WS_POPUP|WS_BORDER|WS_VISIBLE|WS_VSCROLL;
CWnd* parent = nullptr;
if ( m_ParentWindow )
{
parent = m_ParentWindow;
}
else
{
parent= GetParent();
}
BOOL ret = m_ListBox.CreateEx(extendedStyle, _TEXT("LISTBOX"),NULL,style, CRect( 0,0,0,0), parent, 0 , this);
ASSERT( ret);
}
}
And this gets called
int SuggestionListBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CListBox::OnCreate(lpCreateStruct) == -1)
return -1;
m_pEdit = (AutoCompleteEditBox*)lpCreateStruct->lpCreateParams;
return 0;
}
For testing purpose, I created the AutoCompleteEditBox as a child of the top level CDialog and everything works as expected.
Any ideas, suggestions or things I might have missed ?
Thanks,
Max.
=================
I finally fixed the creation issue.
The Edit box created was using the id AFX_PROPLIST_ID_INPLACE; I thought it was OK to continue use it, I replaced the id with a different one and now all is working nicely (well, it is not finished, but I can continue updating and upgrading the feature).
I'd rather be phishing!
modified 5-Feb-16 10:11am.
|
|
|
|
|
Well,
I am not familiar with the class 'CAutoCompleteEditBox' etc. I still use MFC42. This version does not have anything that fancy, but the nearest would be a CComboBox, with the Edit option set to True. Make sure that the Resource Template has the property 'USER_DRAWN' if you want to add your own options. You add these on an EN_CHANGE message.
The best way to investigate this is to open the Resource file in a Text Editor, and inspect and edit the values for the control.
In MFC42 you would be required to, as a minimum, implement the '(On)DrawItem()' virtual function, The Standard Implementation of (On)DrawItem() Asserts in MFC42!
I have in the mean time derived my own libraries for things like this.
Hope this is of help.
Bram van Kampen
modified 1-Feb-16 22:20pm.
|
|
|
|
|
Hi,
Writing a Dialog Based MFC Program, where staff logs in with name and password. I want to implement automatic logging out, after a period of inactivity. (Mouse Moves or Clicks, Keyboard Activity)
I can handle the Internals of how to implement the Cascade Down upon Time_out
I need to monitor 'Activity' I reckon that the best place to do this in SDK is in the App Main Wnd Procedure, by kicking a Timer on WM_MOUSE_MOVE, WM_KEY_UP, etc Messages.
How do I handle this in MFC. Can I use an old fashioned WndProc() or is there no other way but using the MessageMap, with handlers for each message.
Regards,
Bram.
Bram van Kampen
|
|
|
|
|
I have not used MFC for a number of years, but I would guess you can do it in the message map macro, by capturing the messages and writing your own switch handler. You can then reset your timer for each message that is caused by user interaction. Take a look at the source of the macros in the MFC libraries.
|
|
|
|
|
Hi Richard,
Good to hear of you after all this time. Yes, the Macro's is a solution I considered, and I suppose I can write One Handler, to tie to several message ID's, (I know how the Macro's work) with a Macro for each, Just in a standard WndProc() you have only One switch, to filter those out you need to use to kick the timer, before calling the Default in any case. Looks more elegant.
Maybe not feasible in MFC.
Hope you have not given up on MFC. It has a lot to offer compared to those 'Synthetic Languages'.
Good to hear from you again,
Regards,
Bram.
Bram van Kampen
|
|
|
|
|
Bram van Kampen wrote: to filter those out you need to use to kick the timer, before calling the Default I would do it with a simple flag. Each time you handle one of the messages in question, set the flag to true. Each time the timer code gets called set the flag to false. You can then see whether there has been any activity between timer 'ticks'.
Bram van Kampen wrote: Good to hear from you again, Thanks for your kind comments, I've not been away.
|
|
|
|
|
Well Richard,
Maybe I went away!
I'm still working with MFC 42, and DevStudio98. Works fine for me and my Customers. Have no reason to change Dev Platform.
Have built my own MFC Extensions to keep up with the times. Anyways, my market is not cutting edge, and a User Interface with as few changes as possible is most appreciated by my customers. I am proud to say that our user interface has changed very little over the past 30 years, other than in Screen Cosmetics. (We started our enterprise in Win 3.3), and of course there have been many extensions. Our Software ran very well on XP, refused to run on Vista, but, runs with very minor mods, on Win7.
Win8 is a bit of a challenge, Our Software was really never intended to run on a Mobile Phone! (A Sophisticated Cash Register!!), We hope for the best for Win10.
I found a certain amount of hostility on the site against those, like me, who refused to move with the times, and invest large sums in yet another development suite, which would solve problems I did not have in the first place.
Also, there is a learning curve to get familiar with each new edition of the suite, which has a 'Pay-Back' Time only, if it can do things quicker or better.
We never found that to be the case!
The New, as I call 'Synthetic' languages,(C# etc) I as owner, and by vast majority of Staff, will never go for!
At my age, I am not looking for other projects, or chasing new developments, I have a market in which my product sells.
It was just good to hear a familiar voice again, from one who gave us much helpful advice in the past.
Thanks Richard.
Bram van Kampen
|
|
|
|
|
Hi Bram,
I totally agree with what you say about using particular versions of development software, although you do sometimes get forced to upgrade as newer versions of Windows appear. As long as it keeps working, satisfies your customers, and makes a reasonable profit, then there is no real reason to change.
And thanks again for your kind words.
|
|
|
|
|
One solution would be to hook mouse and keyboard events: Hooks Overview (Windows)[^].
The advantage of this solution is that all events for the current desktop are detected regardless which window has the focus and which application is the active one. But it depends on your requirements if you want to reset the timer upon all activities or only upon activities for your application. In the latter case you can still use hooks by checking if your application is the active one and that mouse events are on the application window.
|
|
|
|
|
Well Thanks for your reply.
In my case I only want to monitor Mouse and Key Events in my own application, and want the screens to die, in particular if the App does not have the focus, and Mouse and Key events occur which are sent to another application.
What currently happens is that an employee is performing a Mundane -Idle Task- like pursuing old invoices. The employee is called away, for other more urgent tasks, but remains signed on to an application. Someone else can than a week later resume the Idle Task, under the still open account. I am trying to put a stop to that.
Your contribution has been most helpful,
Regards,
Bram.
Bram van Kampen
|
|
|
|
|
Then using CWinApp::PreTranslateMessage[^] to check for WM_MOUSEMOVE and WM_KEYDOWN might be the simplest solution:
BOOL CMyApp::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_MOUSEMOVE)
{
}
return CWinApp::PreTranslateMessage(pMsg);
}
It may be necessary to add a check for your application being the active one to avoid resetting the timer when the mouse is just moved over it.
|
|
|
|
|
|
Installing a system-wide hook to monitor mouse and keyboard activity would work but is also very "invasive." Another solution would be to call GetLastInputInfo() periodically.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi, Thanks,
The invasive nature of installing a system wide hook for mouse and keyboard activity was really a concern, as appeared to be an overkill. so I have been thinking of using the App Message Map. I am really interested only in a 'Kick to Keep Alive' setup for my Cash Register Application. When the User is away, or, the Computer acting as Cash Register has switched context to another Application (Now THAT is an old fashioned term) the dormant Program should Quietly Log the current User Off!
Your idea is another one worthy of consideration, and further perusal.
Thanks,
Bram van Kampen
|
|
|
|
|
Now ,i have one question. I use library to define a matrix B, for example, as follows, how can i convert B.real() to a double[] array?
thanks very much.
MatrixXcd B(n,3);
for( int i=0; i<n; i++ )
for( int j=0; j<3; j++ )
B(i,j)=0;
|
|
|
|
|
I did not have used it so far but it should be possible to copy the values to your array this way:
double *da = new double[n * 3];
for (int i = 0; i < n; i++)
for (int j = 0; j < 3; j++)
da[i*3 + j] = B(i, j).real();
|
|
|
|
|
Thank you very much.
My code is in Loop many times, so i want a efficient code. your code can reach my function,but efficient i think it's not good.
|
|
|
|
|
It is difficult to answer without knowing how the data are used. But a short web reserach found this: [EIGEN] How to get in and out data from Eigen matrix | Vlad's Blog[^].
So it seems that you can use Map to get a pointer to the complex values. That should be sufficient because the real part is stored first and therefore already at the specified index (when *p is a pointer to a complex array, p[n] and p[n].real() have the same address).
|
|
|
|
|
Hi,
Working with MFC Ribbon designing Ribbon Menu with the help of XML .Now the problem is ,I want to design Menu by single-2 (.bmp)images not by the transparent Images Strip with the help of Index.
I have tried so many ways but don`t get any success.
<CATEGORY>
<ELEMENT_NAME>Category</ELEMENT_NAME>
<NAME>Home-Y</NAME>
<KEYS>H</KEYS>
<IMAGE_SMALL>
<ID>
<NAME>IDB_WRITESMALL</NAME>
<VALUE>110</VALUE>
</ID>
</IMAGE_SMALL>
<IMAGE_LARGE>
<ID>
<NAME>IDB_WRITELARGE</NAME>
<VALUE>111</VALUE>
</ID>
</IMAGE_LARGE>
<PANELS>
<PANEL>
<ELEMENT_NAME>Panel</ELEMENT_NAME>
<NAME>Clipboard</NAME>
<KEYS>D</KEYS>
<INDEX>1</INDEX>
<ELEMENTS>
<ELEMENT>
<ELEMENT_NAME>Button</ELEMENT_NAME>
<ID>
<NAME>ID_EDIT_PASTE</NAME>
<VALUE>57637</VALUE>
</ID>
<TEXT>Paste</TEXT>
<KEYS>V</KEYS>
<INDEX_SMALL>0</INDEX_SMALL>
<INDEX_LARGE>0</INDEX_LARGE>
</ELEMENT>
</ELEMENTS>
</PANEL>
</PANELS>
</CATEGORY>
The most important this, we can not change main tags of XML, beside you can change any thing related IMAGE TAGS,.
|
|
|
|
|
hi all,
i am taking help of this article for printing
Another ListView print (preview) sample.[^]
here i also want to save my print view of doctument to save as pdf.
how can i do this.
please help me for this.
|
|
|
|
|
You need to install a PDF printer driver to use as your destination device. Alternatively you can write the code yourself using a third-party library, or code it from scratch by studying the Adobe PDF specification.
|
|
|
|
|
can u please provide me any example of this.
|
|
|
|
|