|
try this
void CTestdlgDlg::OnButton1()
{
// Two commands here , Both are working.
// TSys.exe is in applicatin path
WinExec("TSys.exe",SW_SHOWNORMAL);
//In a defferent path
WinExec("F:\\GauShare\\TSys.exe",SW_SHOWNORMAL);
//C++ Command
system("F:\\GauShare\\tsys.exe");
}
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
Hi everybody,
I'm trying to change the frame layout dynamically. But I always get
ASSERT_VALID fails with illegal vtable pointer.
ASSERT_VALID fails with illegal vtable pointer.
HEAP[CADSplitterTest.exe]: Invalid allocation size - C02740D0 (exceeded 7ffdefff)
Warning: Uncaught exception in WindowProc (returning -1).
Warning: Window creation failed: GetLastError returns 0x00000578
Warning: couldn't create client pane for splitter.
by the second call trying a CreateView.
Here's my actual code:
BOOL Im_FrameWnd::SetViewLayout(ViewArrangement NewLayout, CCreateContext* ActContext)
{
if ((NewLayout != m_ViewLayout) || (m_Initialize))
{
if (ActContext == NULL)
{
ActContext = &m_Context;
}
if (!m_Initialize)
m_MainSplitter.DestroyWindow();
int HalfWidth, HalfHeight, ThirdWidth, ThirdHeight;
HalfWidth = HalfHeight = ThirdWidth = ThirdHeight = 10;
switch (NewLayout)
{
case TWOVIEWSVERT:
{
m_MainSplitter.CreateStatic(this,1,2, m_Style, AFX_IDW_PANE_FIRST);
/* CalcSizes(HalfWidth, HalfHeight, ThirdWidth, ThirdHeight);
m_MainSplitter.SetColumnInfo(0, HalfWidth, 10);
m_MainSplitter.SetColumnInfo(1, HalfWidth, 10);
*/
m_MainSplitter.CreateView(0,0, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
m_MainSplitter.CreateView(0,1, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
}
break;
case TWOVIEWSHOR:
{
m_MainSplitter.CreateStatic(this,2,1, m_Style, AFX_IDW_PANE_FIRST);
/* CalcSizes(HalfWidth, HalfHeight, ThirdWidth, ThirdHeight);
m_MainSplitter.SetRowInfo(0, HalfHeight, 10);
m_MainSplitter.SetRowInfo(1, HalfHeight, 10);
*/
m_MainSplitter.CreateView(0,0, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
m_MainSplitter.CreateView(1,0, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
}
break;
/* case THREEVIEWSTWOLEFT:
SplitColumn(myRect.Width()/2);
DeleteView(0,0);
BuildChildSplitter(2,TRUE);
/*
m_HelpSplitter1 = new CSplitterWnd();
m_HelpSplitter1->Create(this,1,2, CSize(10,10), NULL,WS_CHILD | WS_VISIBLE, AFX_IDW_PANE_FIRST+10);
CreateView(0,0, NULL);
break;
case THREEVIEWSTWORIGHT:
break;
case THREEVIEWSTWOTOP:
break;
case THREEVIEWSTWOBOTTOM:
break;
*/ case FOURVIEWS:
{
m_MainSplitter.CreateStatic(this,2,2, m_Style, AFX_IDW_PANE_FIRST);
/* CalcSizes(HalfWidth, HalfHeight, ThirdWidth, ThirdHeight);
m_MainSplitter.SetColumnInfo(0, HalfWidth, 10);
m_MainSplitter.SetColumnInfo(1, HalfWidth, 10);
*/
m_MainSplitter.CreateView(0,0, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
m_MainSplitter.CreateView(0,1, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
/* m_MainSplitter.SetRowInfo(0, HalfHeight, 10);
m_MainSplitter.SetRowInfo(1, HalfHeight, 10);
*/
m_MainSplitter.CreateView(1,0, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
m_MainSplitter.CreateView(1,1, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
}
break;
/* case FOURVIEWSTHREELEFT:
break;
case FOURVIEWSTHREERIGHT:
break;
case FOURVIEWSTHREETOP:
break;
case FOURVIEWSTHREEBOTTOM:
break;
*/
default:
{
DWORD TempStyle = WS_CHILD|WS_VISIBLE|WS_BORDER|SPLS_DYNAMIC_SPLIT;
m_MainSplitter.Create(this,2,2, CSize(10,10), ActContext, TempStyle, AFX_IDW_PANE_FIRST);
if (!m_Initialize)
{
m_MainSplitter.CreateView(0,0, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
m_MainSplitter.CreateView(0,1, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
m_MainSplitter.CreateView(1,0, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
m_MainSplitter.CreateView(1,1, m_ViewClass, CSize(HalfWidth,HalfHeight), ActContext);
}
}
break;
}
m_ViewLayout = NewLayout;
RecalcLayout();
}
if (m_Initialize)
m_Initialize = FALSE;
return (TRUE);
}
BOOL Im_FrameWnd::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
m_Context.m_pNewViewClass = pContext->m_pNewViewClass;
m_Context.m_pCurrentDoc = pContext->m_pCurrentDoc;
m_Context.m_pNewDocTemplate= pContext->m_pNewDocTemplate;
m_Context.m_pLastView=NULL;
m_Context.m_pCurrentFrame=this;
m_ViewClass = pContext->m_pNewViewClass;
return SetViewLayout(m_ViewLayout, pContext);
}
Since this is my first trial with CSplitterWnd I don't find the error exactly (I'm afraid it's
my CRuntime Class - but I'm not sure.
Studying the examples brings no help because they only create the layout at generation.
Best regards,
Patrik Müller
|
|
|
|
|
OK - I've found my errors!!
Best regards,
Patrik Müller
|
|
|
|
|
Hi
I've been working the whole day on this problem, but I can't find a solution.
Say I have char as follows:
const char * buf
This char may contain MORE than one \0 character. It may therefore look like "this\0isthewhole\0char"
What I want to do now is to replace all \0 with a "+" or something else.
How can I do it? So far I have this, which doesn't work:
while(*buf++)
{
if(*buf == '\0')
*packet = '+';
else
*packet = *buf;
*packet++;
}
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I might be wrong, but I can't see how your code could work because you don't have a marker to signify the end of the string. Strings like this (that contain nulls) typically contain two nulls at the end so that any code that needs to parse it can find the end. Therefore, in your code that sets this string, you simply need to ensure that it ends with two nulls. From there, the code is farily simple to parse it terminating only when back-to-back nulls have been encountered. Otherwise, you've got no way of knowing when the string ends.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
OK, my fault, you're right..the string contains an \0 at the end.
But how do I get my code to work?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
As I noted, with the string possibly containing a null character before the end, you need to ensure that you have two null characters at the end as the end-delimiter. From there, the code is very simply to parse the array until you hit that delimiter.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Assuming buf is terminated by two null characters, this will do:
for( ; ; ){
char ch=*buf++;
if(ch=='\0'){
*packet++='+';
if(*buff=='\0'){
*packet++='\0';
break;
}
}
else *packet++=ch;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, looks quite correct.
However, is it possible that this will result in an endless-loop if the string is not null-terminated?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
If the string is not (doubly) null-terminated, this will result in the program trying to read beyond the string contents (which can cause a GPF or a meaningless output.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi Gregor
When you have strings that contain nulls or strings that are not not null terminated, you can use the buffer manipulation functions instead of the string manipulation functions. Look them up on MSDN.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
char foo[] = "bar\0baz\0whatever";
std::replace(foo, foo+sizeof(foo), '\0', '+');
|
|
|
|
|
Hi.
I implemented a listview in a program. It works great, but not perfect. I have experience problems. First, the listview insert and display new item perfectly the if it was empty before insertion. For example.
// assume listview is empty
-----
CListView &lc = GetListCtrl();
for (int i = 0; i < 10; ++i)
lc.InsertItem(0, "testing");
-----
The code above will insert ten "testing" strings into the listview control. CListView will update the window with the ten items. However, let say that I want to add more items. Here is a technique I use.
-----
CListView &lc = GetListCtrl();
lc.DeleteAllItems();
int i;
for (i = 0; i < 10; ++i)
lc.InsertItem(i, "testing");
// inserting new lines
for (int j = i; i < 20; ++j)
lc.InsertItem(j, "new items");
Okay. The code above should work. However, sometimes CListView will not display the updated data. Again, in the example above, the program will not update the window with "new items." This seems to happen when I start to add a lot of items (100 or more). Is there some kind of a limit on the CListCtrl?
What is the proper way to add, remove, and clear a CListCtrl *and* properly redraw everything correctly?
Thanks,
Kuphryn
|
|
|
|
|
try doing
lc.UpdateWindow();
at the end of your loop
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
kuphryn wrote:
// inserting new lines
for (int j = i; i < 20; ++j)
lc.InsertItem(j, "new items");
I'd assume this is a typo, but just in case: you should be comparing j not i to 20:
for (int j=i; j<20; ++j)
--------
all the modern things
have always existed
they've just been waiting
to come out
and multiply
and take over Björk, The Modern Things
|
|
|
|
|
Try this for appending content to your list control:
for (int j=lc.GetItemCount(); (j < 20); ++j) {
lc.InsertItem (j, "A new item");
}
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks.
The reason it did not update the screen was because the window was focused. The solution is to redraw whenever the window is in focus.
Kuphryn
|
|
|
|
|
Thanks.
The reason it did not update the screen was because the window was focused. The solution is to redraw whenever the window is in focus.
Kuphryn
|
|
|
|
|
I am making a dialog based program with MFC and now I want to make a new class for node-management. But when I try to make one in classwizard it wants me to derive it from another class... but I don't want to. Or which class should I derive it from?
|
|
|
|
|
What about right click on the ClassView (TreeView at your left), New Class
and then make sure that the Combo named "Class Type" says Generic Class.
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Hey...I'm making a program in Win API with <windows.h>...
I'm having a problem where my program will look fine in one resolution, like 800x600, but when I run the program in 640x480 or 1024x768, it's much bigger or smaller than it should be.
Is there some sort of way to get the screen size and size the window according to it? How can I do this? Help would be appreciated =)
Thanks - Dave
|
|
|
|
|
Sure. Do this to get the screen size:
RECT rectScreen;
VERIFY (GetWindowRect (GetDesktopWindow()), &rectScreen));
or
RECT rectScreen;
VERIFY (SystemParametersInfo (SPI_GETWORKAREA, 0, &rectScreen, 0));
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
does anybody know of a way to create a small program (ie what functions to use) that can change the icons of executables, similar to a pared down MicroAngelo or IconChanger? I was looking at BeginResourceUpdate() etc, but they are NT-only. My program copies an executable to another folder with certain settings stored in an INI file; I want the user to be able to choose the icon of the executable, thus I need to change it when it is copied (hope that makes sense). Is there a good way of doing this?
If anybody has any ideas, I would be very grateful.
Many thanks,
Keith
|
|
|
|
|
As you pointed out, BeginResourceUpdate and related functions are NT/2k/XP only. Fortunately, Erik Kallen wrote an amazing clone of this set of functions that works for 9x/ME systems as well: see his article Updating Resources on Win9x.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your reply, I'll check it out.
Cheers,
Keith
|
|
|
|
|