|
|
This doesn't even repaint the current view...
|
|
|
|
|
OK, nevermind that, that was my bad.
But what I need to do is repaint all views of all documents
|
|
|
|
|
AfxGetMainWnd()->Invalidate() is one way.
|
|
|
|
|
I tried, but that didn't seem to update any windows? Hmm maybe I did it a bit wrong.. I'll see...
Nope, doesn't effect the child windows...
|
|
|
|
|
Hi,
I have a windows handle which is returned by third party lib, this handle sometimes is valid, sometimes isn't. I want to know whether there is method or function to judge the validity of a handle?
Thanks,
Jeff Xi
|
|
|
|
|
|
Roman Fadeyev wrote:
GetHandleInformation()
Beware that function only works in Windows NT, it is not supported for Win9x OSs
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
There are ways, but it depends on the type of handle that you are dealing with.
Do you have a window handle, a GDI handle, a file handle, or something else?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
If it's a handle to a window, you can call IsWindow().
For other handles and Win98 compatibility, you could use DuplicateHandle() and check the error returns (don't forget to close the duplicated handle if successful.)
|
|
|
|
|
I'd like to detect the folder (path) where a my application is running
and put the data in a string. - Can somebody give me some suggestion
(without using the system() funcion)? - Thanks - giovanni.
|
|
|
|
|
If you mean the path where your .exe is located, you can use a function:
GetModuleFileName(...), where you put your exe module instance handle and retrieve the whole path including the exe module ("c:\windows\notepad.exe"). Then you have to simply strip the exe name and voila you have path.
If you mean the current directory for process, use GetCurrentDirectory()
|
|
|
|
|
geo_m is completely right. But I would add little remark: you can pass NULL to GetModuleFileName() to retrieve your app path. It's easier to use. Especially it is important to pass NULL when you get AppPath from DLL.
How to cut filedir from path? All functions for manipulating with filenames are placed in shlwapi.h. Their names are beginning from "Path" word. For example: PathFindFileName (Searches a path for a file name). Also you can use C++ function _splitpath
|
|
|
|
|
An example:
char szDrive[_MAX_DRIVE];
char szDir[_MAX_DIR];
char szFileName[_MAX_FNAME];
char szExt[_MAX_EXT];
char szBuffer[_MAX_PATH];
// get path of executable
GetModuleFileName(NULL, szBuffer, _MAX_PATH);
// split into parts, to get the Path
const char* pFilePath = szBuffer;
_splitpath(pFilePath, szDrive, szDir, szFileName, szExt);
CString strPath;
strPath.Format("%s%s", szDrive, szDir);
TRACE("File Path is %s\n", strPath);
Gaulles
|
|
|
|
|
void getAppDir
(CString& strAppDir)
{
char* pSlash = NULL;
char szFilespec [_MAX_PATH];
::GetModuleFileName (AfxGetInstanceHandle(), szFilespec, _MAX_PATH);
pSlash = strrchr (szFilespec, '\\');
ASSERT (pSlash != NULL);
pSlash++;
*pSlash = '\0';
strAppDir = szFilespec;
} /ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
use GetModuleFileName()
Hari Krishnan
|
|
|
|
|
I came across a math problem that i have no clue how to write a program for it.
It says to arrange the numbers 1 through 30 so that the sum of any 2 consecutive integers is a perfect square (i.e. 4,16,25,36,49...). I found what i think is a small pattern
15 1 24
14 2 23
13 3 22
12 4 21
11 5 20
30 6 19
29 7 18
28 8 17
27 9 16
26 10 25
but anyways, i need to know how to write a prog. that will either arrange these sets of numbers or arrange 1-30 the right way. I would really appreciate help on this one
thanks
aaron barker
|
|
|
|
|
Arranging as circle or floating from the ends?
RJS
|
|
|
|
|
well, im sort of a newb. basically, just have the numbers be arranged any way possible to make any 2 integers added together a perfect square.
like,
15,1,24,12,4,21
i dont really know how to explain it anymore
|
|
|
|
|
When you say *need* to know, is this something you have personal need for, or is it your homework ?
Think about what you want the program to do. How would you do it manually ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Here's what you asked for, assuming that you have Hexium or 80686 processor (searching within 30! (i.e 30*29*28..*1) elements):
#include <stdio.h>
int Check(int,int);
main()
{
for(int j1=1;j1<31;j1++)
for(int j2=1;j2<31;j2++){if(j2==j1)continue;
for(int j3=1;j3<31;j3++){if(j3==j2 || j3==j1)continue;
for(int j4=1;j4<31;j4++){if(j4==j3 || j4==j2 || j4==j1)continue;
for(int j5=1;j5<31;j5++){if(j5==j4 || j5==j3 || j5==j2 || j5==j1)continue;
for(int j6=1;j6<31;j6++){if(j6==j5 || j6==j4 || j6==j3 || j6==j2 || j6==j1)continue;
for(int j7=1;j7<31;j7++){if(j7==j6 || j7==j5 || j7==j4 || j7==j3 || j7==j2 || j7==j1)continue;
for(int j8=1;j8<31;j8++){if(j8==j7 || j8==j6 || j8==j5 || j8==j4 || j8==j3 || j8==j2 || j8==j1)continue;
for(int j9=1;j9<31;j9++){if(j9==j8 || j9==j7 || j9==j6 || j9==j5 || j9==j4 || j9==j3 || j9==j2 || j9==j1)continue;
for(int j10=1;j10<31;j10++){if(j10==j9 || j10==j8 || j10==j7 || j10==j6 || j10==j5 || j10==j4 || j10==j3 || j10==j2 || j10==j1)continue;
for(int j11=1;j11<31;j11++){if(j11==j10 || j11==j9 || j11==j8 || j11==j7 || j11==j6 || j11==j5 || j11==j4 || j11==j3 || j11==j2 || j11==j1)continue;
for(int j12=1;j12<31;j12++){if(j12==j11 || j12==j10 || j12==j9 || j12==j8 || j12==j7 || j12==j6 || j12==j5 || j12==j4 || j12==j3 || j12==j2 || j12==j1)continue;
for(int j13=1;j13<31;j13++){if(j13==j12 || j13==j11 || j13==j10 || j13==j9 || j13==j8 || j13==j7 || j13==j6 || j13==j5 || j13==j4 || j13==j3 || j13==j2 || j13==j1)continue;
for(int j14=1;j14<31;j14++){if(j14==j13 || j14==j12 || j14==j11 || j14==j10 || j14==j9 || j14==j8 || j14==j7 || j14==j6 || j14==j5 || j14==j4 || j14==j3 || j14==j2 || j14==j1)continue;
for(int j15=1;j15<31;j15++){if(j15==j14 || j15==j13 || j15==j12 || j15==j11 || j15==j10 || j15==j9 || j15==j8 || j15==j7 || j15==j6 || j15==j5 || j15==j4 || j15==j3 || j15==j2 || j15==j1)continue;
for(int j16=1;j16<31;j16++){if(j16==j15 || j16==j14 || j16==j13 || j16==j12 || j16==j11 || j16==j10 || j16==j9 || j16==j8 || j16==j7 || j16==j6 || j16==j5 || j16==j4 || j16==j3 || j16==j2 || j16==j1)continue;
for(int j17=1;j17<31;j17++){if(j17==j16 || j17==j15 || j17==j14 || j17==j13 || j17==j12 || j17==j11 || j17==j10 || j17==j9 || j17==j8 || j17==j7 || j17==j6 || j17==j5 || j17==j4 || j17==j3 || j17==j2 || j17==j1)continue;
for(int j18=1;j18<31;j18++){if(j18==j17 || j18==j16 || j18==j15 || j18==j14 || j18==j13 || j18==j12 || j18==j11 || j18==j10 || j18==j9 || j18==j8 || j18==j7 || j18==j6 || j18==j5 || j18==j4 || j18==j3 || j18==j2 || j18==j1)continue;
for(int j19=1;j19<31;j19++){if(j19==j18 || j19==j17 || j19==j16 || j19==j15 || j19==j14 || j19==j13 || j19==j12 || j19==j11 || j19==j10 || j19==j9 || j19==j8 || j19==j7 || j19==j6 || j19==j5 || j19==j4 || j19==j3 || j19==j2 || j19==j1)continue;
for(int j20=1;j20<31;j20++){if(j20==j19 || j20==j18 || j20==j17 || j20==j16 || j20==j15 || j20==j14 || j20==j13 || j20==j12 || j20==j11 || j20==j10 || j20==j9 || j20==j8 || j20==j7 || j20==j6 || j20==j5 || j20==j4 || j20==j3 || j20==j2 || j20==j1)continue;
for(int j21=1;j21<31;j21++){if(j21==j20 || j21==j19 || j21==j18 || j21==j17 || j21==j16 || j21==j15 || j21==j14 || j21==j13 || j21==j12 || j21==j11 || j21==j10 || j21==j9 || j21==j8 || j21==j7 || j21==j6 || j21==j5 || j21==j4 || j21==j3 || j21==j2 || j21==j1)continue;
for(int j22=1;j22<31;j22++){if(j22==j21 || j22==j20 || j22==j19 || j22==j18 || j22==j17 || j22==j16 || j22==j15 || j22==j14 || j22==j13 || j22==j12 || j22==j11 || j22==j10 || j22==j9 || j22==j8 || j22==j7 || j22==j6 || j22==j5 || j22==j4 || j22==j3 || j22==j2 || j22==j1)continue;
for(int j23=1;j23<31;j23++){if(j23==j22 || j23==j21 || j23==j20 || j23==j19 || j23==j18 || j23==j17 || j23==j16 || j23==j15 || j23==j14 || j23==j13 || j23==j12 || j23==j11 || j23==j10 || j23==j9 || j23==j8 || j23==j7 || j23==j6 || j23==j5 || j23==j4 || j23==j3 || j23==j2 || j23==j1)continue;
for(int j24=1;j24<31;j24++){if(j24==j23 || j24==j22 || j24==j21 || j24==j20 || j24==j19 || j24==j18 || j24==j17 || j24==j16 || j24==j15 || j24==j14 || j24==j13 || j24==j12 || j24==j11 || j24==j10 || j24==j9 || j24==j8 || j24==j7 || j24==j6 || j24==j5 || j24==j4 || j24==j3 || j24==j2 || j24==j1)continue;
for(int j25=1;j25<31;j25++){if(j25==j24 || j25==j23 || j25==j22 || j25==j21 || j25==j20 || j25==j19 || j25==j18 || j25==j17 || j25==j16 || j25==j15 || j25==j14 || j25==j13 || j25==j12 || j25==j11 || j25==j10 || j25==j9 || j25==j8 || j25==j7 || j25==j6 || j25==j5 || j25==j4 || j25==j3 || j25==j2 || j25==j1)continue;
for(int j26=1;j26<31;j26++){if(j26==j25 || j26==j24 || j26==j23 || j26==j22 || j26==j21 || j26==j20 || j26==j19 || j26==j18 || j26==j17 || j26==j16 || j26==j15 || j26==j14 || j26==j13 || j26==j12 || j26==j11 || j26==j10 || j26==j9 || j26==j8 || j26==j7 || j26==j6 || j26==j5 || j26==j4 || j26==j3 || j26==j2 || j26==j1)continue;
for(int j27=1;j27<31;j27++){if(j27==j26 || j27==j25 || j27==j24 || j27==j23 || j27==j22 || j27==j21 || j27==j20 || j27==j19 || j27==j18 || j27==j17 || j27==j16 || j27==j15 || j27==j14 || j27==j13 || j27==j12 || j27==j11 || j27==j10 || j27==j9 || j27==j8 || j27==j7 || j27==j6 || j27==j5 || j27==j4 || j27==j3 || j27==j2 || j27==j1)continue;
for(int j28=1;j28<31;j28++){if(j28==j27 || j28==j26 || j28==j25 || j28==j24 || j28==j23 || j28==j22 || j28==j21 || j28==j20 || j28==j19 || j28==j18 || j28==j17 || j28==j16 || j28==j15 || j28==j14 || j28==j13 || j28==j12 || j28==j11 || j28==j10 || j28==j9 || j28==j8 || j28==j7 || j28==j6 || j28==j5 || j28==j4 || j28==j3 || j28==j2 || j28==j1)continue;
for(int j29=1;j29<31;j29++){if(j29==j28 || j29==j27 || j29==j26 || j29==j25 || j29==j24 || j29==j23 || j29==j22 || j29==j21 || j29==j20 || j29==j19 || j29==j18 || j29==j17 || j29==j16 || j29==j15 || j29==j14 || j29==j13 || j29==j12 || j29==j11 || j29==j10 || j29==j9 || j29==j8 || j29==j7 || j29==j6 || j29==j5 || j29==j4 || j29==j3 || j29==j2 || j29==j1)continue;
for(int j30=1;j30<31;j30++){if(j30==j29 || j30==j28 || j30==j27 || j30==j26 || j30==j25 || j30==j24 || j30==j23 || j30==j22 || j30==j21 || j30==j20 || j30==j19 || j30==j18 || j30==j17 || j30==j16 || j30==j15 || j30==j14 || j30==j13 || j30==j12 || j30==j11 || j30==j10 || j30==j9 || j30==j8 || j30==j7 || j30==j6 || j30==j5 || j30==j4 || j30==j3 || j30==j2 || j30==j1)continue;
if(Check(j1,j2)&&Check(j2,j3)&&Check(j3,j4)&&
Check(j4,j5)&&Check(j5,j6)&&Check(j6,j7)&&
Check(j7,j8)&&Check(j8,j9)&&Check(j9,j10)&&
Check(j10,j11)&&Check(j11,j12)&&Check(j12,j13)&&
Check(j13,j14)&&Check(j14,j15)&&Check(j15,j16)&&
Check(j16,j17)&&Check(j17,j18)&&Check(j18,j19)&&
Check(j19,j20)&&Check(j20,j21)&&Check(j21,j22)&&
Check(j22,j23)&&Check(j23,j24)&&Check(j24,j25)&&
Check(j25,j26)&&Check(j26,j27)&&Check(j27,j28)&&
Check(j28,j29)&&Check(j29,j30)){
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d ",
j1,j2,j3,j4,j5,j6,j7,j8,j9,j10,j11,j12,j13,j14,j15,j16,j17,j18,j19,j20,j21,j22,j23,j24,j25,j26,j27,j28,j29,j30);
getchar();
return 0;}
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
printf("\nNo solution!.");
getchar();
return 0;
}
int Check(int x,int y)
{
int c=x+y;
if(c==4 || c==9 || c==16 || c==25 || c==36 || c==49) return 1;
else return 0;
}
Zarzor
ZARZOR13
|
|
|
|
|
You are a bad guy;)
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
Sorry....what you said ?.
ZARZOR13
|
|
|
|
|
Come down!
1 24 25 11 5 4 12 13 3 6 30 19 17 8 28 21 15 10 26 23 2 14 22 27 9 16 20 29 7 18
You must modify my previous code by adding to each "for" loop (start from j2 loop) in "if" statment the following statment: || !Check(jx,jy)
where jx is the current loop, and jy is the previous loop. e.g.
for(int j2=1;j2<31;j2++){if(j2==j1 || !Check(j1,j2))continue;
Hence,you can reduce the running time from few weeks to few seconds !!
You welcome for any Math problem.
ZarZor
ZARZOR13
|
|
|
|
|
I have this code in my program:
Tmp = theApp.Directory + "\\WulframAutoUpdater.exe";<br />
Both Tmp and Directory are CString's, and directory have a directory location in it. But, for some reason, Tmp is set to "\\WulframAutoUpdater.exe", without the directory string. Why is it doing that?
Thanks!
|
|
|
|
|