|
Hi All,
I am writing an outlook style program and I want to be able to put CView derived classes in dll's to keep them seperate from the main application, problem is though that I also want to keep all data in the CDocument derived class which is in my EXE. Unfortunately it seems that the only things that can be accessed from the DLL's are the CDocument methods and not those in my own custom CDocument derived class. If I type cast ie. (MyDoc*)CDocument(), I get the unresolved symbol linker error, which leads me to believe I will have to put all of my data classes in each dll and compile them in there too. Is there anyway to avoid having to do this as it seems like more work than just keeping all of the CView derived classes in the main EXE, even though it seems messier.
Cheers,
Clint
|
|
|
|
|
Hi,
I'm using MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT to delete some temporary files if the user reboots the PC whilst using my program (XP/2000/NT - I'm using WinInit.INI for other systems). However, if the program closes normally, I need to cancel the MOVEFILE_DELAY_UNTIL_REBOOT for all the temporary files that it has been set for.
According to MSDN, MoveFileEx "stores the locations of the files to be renamed at restart in the following registry value:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
This registry value is of type REG_MULTI_SZ. Each rename operation stores the following pair of NULL-terminated strings:
szDstFile\0\0
szSrcFile\0szDstFile\0\0"
I checked the registry using regedit, and found all the values there as specified, and discovered that, say if the file to be deleted is "c:\\test\test.exe", then it would be listed in the registry as:
\??\c:\\test\test.exe
Thus, to cancel all of registry entries, I tried this:
[code]
HKEY hKey;
char szRegKey[MAX_PATH];
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\PendingFileRenameOperations",
0,KEY_ALL_ACCESS,&hKey);
//this part should be looped for each file to be deleted:
strcpy(szRegKey,"\\??\\");
strcat(szRegKey,szFileToDelete);
RegDeleteValue(hKey,szRegKey);
RegCloseKey(hKey);
[/code]
However, this didn't work - all the entries in the registry were left just as they were.
Could anybody tell me where I am going wrong, and how to correct this so that I can delete all of the registry values that were added by MoveFileEx?
Any help much appreciated,
Many thanks,
KB
|
|
|
|
|
Can anybody help?
I discovered that my problem was that the strings I was trying to delete individually weren't the registry values, but "PendingFileRenameOperations" was the value - which I was treating as a key.
Thus, I can use this code successfully to remove "PendingFileRenameOperations", the value created by MoveFileEx:
[code]
HKEY hKey;
char szRegKey[MAX_PATH];
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Session Manager",
0,KEY_ALL_ACCESS,&hKey);
RegDeleteValue(hKey,"PendingFileRenameOperations");
RegCloseKey(hKey);
[/code]
The problem with this, of course, is that if any other programs have used MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT, then my program will delete all this info too, which is undesirable.
Does anyone know how I can delete *only* the strings that my program has added to the PendingFileRenameOperations value?
Or, is there a function that will allow me to back up the original "PendingFileRenameOperations" value when my program starts (eg. by copying it with a different name), then add the values I need, then if my program ends normally I can replace the updated "PendingFileRenameOperations" with the backup (so that in effect the values I have added are deleted)?
Many thanks for any help,
KB
|
|
|
|
|
Ah, figured it out. I just use RegQueryValueEx to get the value of PendingFileRenameOperations when the program starts. If it returns ERROR_SUCCESS, I just replace the changed value with the saved value when the program ends using RegSetValueEx, otherwise I delete PendingFileRenameOperations using RegDeleteValue().
Thanks anyway,
KB
|
|
|
|
|
hi...
Usually the list ctrl's entire client rect is white by default.
If i want to have a different bk color when it gets the focus and also when it looses the focus.
Any help is appreciated.
Thanx
saleem
|
|
|
|
|
One solution is to derive a class from CListCtrl and do custom drawing.
Kuphryn
|
|
|
|
|
|
Michael Dunn wrote:
Ericahist updated Aug 30!
Does she know she has a stalker by the way?
--
Frivolous Theorem of Arithmetic: Almost all natural numbers are very, very, very large.
|
|
|
|
|
just call CListCtrl::Setbkcolor(RGB(255, 255, 255)); //the color you want
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I have two applications and an event in one of the applications posts a message to the other application. I'm receiving the message in my second application with OnCopyData(). The message is being received but the receiving application remains in the background behind the window for the sending application.
I want to make the receiving application become the front-most and active window when it receives the message. I tried adding this code to OnCopyData():
SetForegroundWindow();<br />
SetActiveWindow();<br />
SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
This seems to cause the receiving application's button on the Taskbar to flash but it's still visually behind the sending application's window.
What am I doing wrong here?
|
|
|
|
|
|
|
Hi!
I'm wondering what's the best way to skin my app?! I've build it with Borland's C++ Enterprise 6.
Already found a lot of ways and .classes, but everybody says something else.
For example;
http://www.codeproject.com/info/search.asp?target=skin&st=kw&qm=all
There must be a relatively easy way to do this?!
Thx 4 thinking with me.
Regards, Roland.
|
|
|
|
|
AFAIK I'm afraid not - you are on the right track with what you have found.
Skinning an application literally involves stopping windows drawing the various windows/controls and doing the drawing yourself. Many of the techniques you'll see involve taking an MFC class and modifying/overriding the code that actually draws that control - this gives you the look you want while retaining the all functionality. I particularly like the work by Davide Calabro - you can learn alot from this.
Phil
|
|
|
|
|
how to get the number of digits after the decimal point
ex :
Input : 5.1234
Expected Output : 4
i wrote this code but there are wornings..
what is wrong here ??
double input;
int x=input; // so x=the integeral part of input
int y=input-x; // so y=the fractional part
while(y>0)
{count++;
input*=10;
x=input;
y=input-x;
}
plz help me !!
elmahdy
ahmed elmahdy
|
|
|
|
|
First, this really sounds like homework. Not that such such posts are prohibited, but you may get a quicker response just reading ahead in your text book.
Anyway, two hints:
1) int s won't hold the fractional bits of a number.
2) converting a number from one type to another, when the second type is not able to correctly represent all values possible in the first, will cause compiler warnings.
Shog9
I returned and saw under the sun,
that the race is not to the swift,
nor the battle to the strong...
|
|
|
|
|
Given that 5.1234 is not going to represented exactly as such in memory (i.e., it's more than likely going to be something like 5.123999), you're going to have a hard time using your current code, assuming it even works.
elmahdy wrote:
int y=input-x; // so y=the fractional part
The problem with this is that 5.1234 - 5 = 0.1234 in memory, but only the 0 gets assigned to variable y . Make sense?
You could try converting the number to a string, but most of the conversion routines want to know how many digits to put after the decimal, which sort of defeats the purpose!
|
|
|
|
|
Where is the value of input coming from?
If you are getting it from the console, then use scanf with a string type specifier.
Get the length of that string
Start at the 0th char
Increment the index until you find the '.'
The number of decimal places is the string length - the current index (assuming you pre-increment)
|
|
|
|
|
Here is one solution, but it is fraught with problems, I will let you work out what they are!
#include <math.h><br />
#include <stdio.h><br />
<br />
int main(int argc, char* argv[])<br />
{<br />
<br />
double dVal = 5.1234,<br />
dResult = 0.9,<br />
dInt = 0.0;;<br />
<br />
int nKount = 0;<br />
<br />
while(dResult > 0.00001)<br />
{<br />
dVal *= 10.0;<br />
<br />
dResult = modf(dVal, &dInt);<br />
<br />
nKount++;<br />
}<br />
<br />
printf("Value = %d\n", nKount);<br />
return 0;<br />
}
It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman
|
|
|
|
|
What is the c++ version of this in c#?
string[][] a two diminsion string array.
I just want std c++ if possible.
Thank You
Bo Hunter
|
|
|
|
|
|
The brackets are (unfortunately) tied to the variable name instead of the type. So your example is the correct way to do it in C++.
--
Frivolous Theorem of Arithmetic: Almost all natural numbers are very, very, very large.
|
|
|
|
|
In Java, brackets can go either with variable or type. Crazy...
|
|
|
|
|
Yes its really bothering me.... I have a CTreeCtrl on a modeless dialog, When a selection is made on the list control that is on the dialog box I want another class, generic, to parse out the contents to the related file... how can I do this? I understand that I can't pass a CTreeCtrl as a return value from the generic class (CParseDocument) and I can't get the generic class to get control of the Dialog class and make it update the control.
Also I'm using another class for this to organize it and it gets really messy if I keep the parsing in the Dialog class.
Heres what I've been trying to get to work (it keeps returning NULL):
TV_INSERTSTRUCT tv_is;
tv_is.hParent = TVI_ROOT;
tv_is.hInsertAfter = TVI_LAST ;
tv_is.item.mask = TVIF_TEXT;
tv_is.item.pszText = ConvertCStringToChar(m_strSectionName);
hSectionRoot = m_cSlidOpen.m_ctrlXMLTree.InsertItem(&tv_is);
if (hSectionRoot==NULL)
{
AfxMessageBox("failed");
return;
}
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|