|
WM_KICKIDLE defined in AFXPRIV.H header file
Philip Patrick
"Two beer or not two beer?" <shakesbeer>
Web-site: www.saintopatrick.com
|
|
|
|
|
Does anyone know of a way (I would guess it would use macro's) to execute a string which represents a line of code I want to execute.
example:
CString strCode = _T("int nVariable = 3;");
-And now execute it. I know it could be done with interpreted languages like python, but I don't know about C++.
-JD
|
|
|
|
|
What do you mean "execute it"? Show it in a dialog box?
Show the string in a dialog box (MFC):
AfxMessageBox(strCode);
or Win32
::MessageBox(hWnd,strCode,"Title", MB_OK);
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
I don't see how it could be done in a compiled language like C++.
However, if you can move your dynamic code to a different language (eg: Tcl), you could load an interpreter from within your C/C++ code and execute the code within the interpeter (eg: by using TclEval()).
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
You need to implement WSH host scripting. Then you should be able to use VBScript/Javascript to execute code, fire events etc...
See
http://www.codeguru.com/atl/ATL_ScriptHost.shtml
|
|
|
|
|
It can be done but it is a HUGE amount of work and, in most cases, not worth the effort. I implemented an on-the-fly machine code generator for the script engine in my company's product and it was not an easy task at all. This is similar to what JIT compilers for Java do. I actually know very little about assembly code. I just stared at a whole bunch of .cod files emitted by VC++ and sorted out how it works. Curiously, I found that VC++ only uses three data registers to do everything. Another curiosity is that the this pointer for C++ methods is not passed on the stack. It is loaded into ECX prior to the call.
Anyway, What it amounts to is you build a block of bytes of data that are machine code and set a pointer to a function to the address of the block and (*execute_it).
I think an interpreted language is probably the easiest way to go about this and there are many of them.
|
|
|
|
|
> Another curiosity is that the this pointer for C++ methods
> is not passed on the stack. It is loaded into ECX prior to
> the call.
Just an FYI: IIRC, that is the "thiscall" calling convention.
Peace!
-=- James.
|
|
|
|
|
Yes, I know it is the thiscall convention. What is amusing is that the VC++ docs describe this correctly in one place and incorrectly in another. Here is the wrong description :
This is the default calling convention used by C++ member functions that do not use variable arguments. The callee cleans the stack, so the compiler makes vararg functions __cdecl, and pushes the this pointer on the stack last.
I have seen many people refer to this being pushed on the stack and that is not what VC does. There may be some compilers that do though. I don't know for sure.
|
|
|
|
|
You need an interpreter of commands, I made a interpreter for FTP a couple of years ago, it's the only solution...
Best Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
What fun! I designed and programmed ATE to test microcircuits, functional and in-circuit, and a cute little HP9825 desktop calculator ran the whole thing. You typed code into it's 64K memory, then saved the program on an 8" floppy disk. It's native language was hpl, which quickly expired because nobody liked a funny looking language (it used lower case). I liked it because one of the storable functions was the <Store> key. Once stored, the characters were treated as a command. That let me write programs that modified their behavior to adapt to the environment (and I mean physical - EMI, temp, etc.) and increase the accuracy of measurements on the circuit. It drove the QC people nuts to have programs around that kept changing themselves
Let's bring back hpl!!!!
|
|
|
|
|
You have to embed an interpreter in your program. There are plenty out there that are free and can be integrated into a C++ program.
http://www.lua.org/
Todd Smith
|
|
|
|
|
Hello -
I'm having some novice problems with using the Replace() method of CImageList. The Add() method allows for a COLORREF to be used for the mask color, but Replace makes you supply a CBitmap for the mask.
Does the bitmap mask need to be custom generated for each bitmap that I want to insert (via Replace) into the imagelist? All of my images have a standard background color (RGB(192,192,192)), so it would be great if I could do:
m_imagelist->Replace(iOld, pNewBitMap, RGB(192,192,192));
My images are loaded into the imagelist at runtime. Other than the background color and size, I don't have any compile-time knowledge of their content.
Currently, I'm doing something like this:
void CSomeView::OnInitialUpdate()
{
...
m_imagelist.Create(16, 16, ILC_MASK | ILC_COLOR8, 0, 0);
m_imagelist.SetImageCount(20);
...
GetTreeCtrl().SetImageList(&m_imagelist, TVSIL_NORMAL);
...
}
void CSomeView::OnSomeEvent(...)
{
// IDB_MASK is a 16x16 monochrome bitmap
// that's all RGB(192,192,192)
CBitmap *pbmpMask = new CBitmap();
pbmpMask->LoadBitmap(IDB_MASK);
// load some bitmap from a file
hBitmap = (HBITMAP)::LoadImage(NULL,
strPathToTheFiles + "SomeFile.bmp",
IMAGE_BITMAP, 16, 16,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
CBitMap *pBM = new CBitmap();
pBM->Attach(hBitmap);
m_imagelist.Replace(iSomeIndex, pBM, pbmpMask);
GetTreeCtrl().Invalidate();
}
I've tried several other approaches, but nothing gives me the transparent background. So... Do I need to build a bitmap mask for each bitmap using ::BitBlt and friends?
Thanks,
David Emery
|
|
|
|
|
Did you change back the Imagelist in the Tree control, like you did
in your OnInitialUpdate()?
I am not sure if just Invalidate() the tree control really fix your problem.
Did I really catch your problem?
- God bless the World
|
|
|
|
|
Yes, I do a SetImageList after the Replace(s). Sorry, I somehow left that out of the code snippet that I posted. The snip should be something like this:
void CSomeView::OnSomeEvent(...)
{
...
m_imagelist.Replace(iSomeIndex, pBM, pbmpMask);
GetTreeCtrl().SetImageList(m_pImageList, TVSIL_NORMAL);
GetTreeCtrl().Invalidate();
}
I'm messing with some code right now that generates a mask from the image that is being inserted into the imagelist. I'm having a little taste of success, but darn I wish that Replace() just would let me send a COLORREF instead of a CBitmap mask.
My mask generation looks like this. It works for the first image, but not subsequent, so still having some problems. Do you see my error(s)?
void CSomeView::OnSomeEvent(...)
{
...
CBitmap *pMask = GetMask(pBM);
m_imagelist.Replace(iSomeIndex, pBM, pMask);
GetTreeCtrl().SetImageList(m_pImageList, TVSIL_NORMAL);
GetTreeCtrl().Invalidate();
}
CBitmap *CSomeView::GetMask(CBitmap *pImage)
{
HBITMAP hbmMask = NULL;
BITMAP bm;
// get bitmap size info
pImage->GetBitmap(&bm);
// Create memory DCs to work with.
HDC hdcMask = ::CreateCompatibleDC(NULL);
HDC hdcImage = ::CreateCompatibleDC(NULL);
// Create a monochrome bitmap for the mask.
hbmMask = ::CreateBitmap(bm.bmWidth, bm.bmHeight,
1, 1, NULL);
// Select the mono bitmap into its DC.
HBITMAP hbmOldMask = (HBITMAP)::SelectObject(hdcMask,
(HBITMAP)hbmMask);
// Select the image bitmap into its DC.
HBITMAP hbmOldImage = (HBITMAP)::SelectObject(hdcImage,
pImage->m_hObject);
// Set the transparency color to be the top-left pixel.
// ::SetBkColor(hdcImage, ::GetPixel(hdcImage, 0, 0));
// force transparency color
::SetBkColor(hdcImage, RGB(192,192,192));
// Make the mask.
::BitBlt(hdcMask, 0, 0, bm.bmWidth, bm.bmHeight,
hdcImage, 0, 0, SRCCOPY);
// Tidy up.
::SelectObject(hdcMask, hbmOldMask);
::SelectObject(hdcImage, hbmOldImage);
::DeleteDC(hdcMask);
::DeleteDC(hdcImage);
CBitmap *pBM = new CBitmap();
pBM->Attach(hbmMask);
return pBM;
}
Thanks for your reply.
|
|
|
|
|
I wish that I understand what you are trying to accomplish.
1)If you plan to replace the bitmap, why you are not using the
State bitmap instead. GetTreeCtrl().SetImageList(m_pImageList, TVSIL_STATE); .
I don't feel that you use the mask for anything else than changing
the background color of your bitmap.
2)I didn't see any apparent problem with your mask method but I question if you really
need to create a mask since you plan to change the entire bitmap index.
- God bless the World
|
|
|
|
|
>> I wish that I understand what you are trying to accomplish.
I can't really describe the app's usage other than it's a tool for the battlefield.
The application receives CORBA messages that contains an index number and a filename. I need to read the file, convert it to a bitmap (the file can be a bmp, jpg, or gif), and store it into an imagelist using the index number. I receive a bunch of these messages at startup and then any number of messages throughout the app's lifetime. I have no control over when or why these messages will come. Sometimes the new image is a thumbnail of some dynamic situation.
I also then receive updates to items that reference the imagelist. These updates may include changes to the image index number. These items are blobs on a map, tree nodes, tabs, toolbar buttons, menu items, etc.
>> why you are not using the State bitmap instead.
That would only help if my item was selected or not. I need to dynamically update any and all images.
>> I don't feel that you use the mask for anything else than changing the background color of your bitmap.
When I started this, I guess I didn't understand masks. I thought that I just needed to specify a transparency color. What it seems is that there is a one-to-one mask image for every bitmap image in the image list. When you do an imagelist->Add(pImage, COLORREF), the imagelist generates your mask image for you. When you do a imagelist->Replace(pImage, pMask), you must manually create the mask yourself.
>> I question if you really need to create a mask since you plan to change the entire bitmap index.
I didn't think that I needed to create a mask either. I searched everywhere to try and find some example code of the Replace method.
The GetMask code that I posted yesterday does work. For every image that I Replace(), I must create a unique mask.
Thanks for your time and help.
|
|
|
|
|
I can only give you ideas that could work in your case since I did
similar things with a ListView.
1. In my case, I didn't create a mask so when I call Create() for the ImageList, the
crMask was set to CLR_NONE (0) but I guess in your case you should probably use RGB(192,192,192).
2. I also use the default color: ILC_COLOR (0) not ILC_COLOR8 but I understand why you are using it.
3. AFAIK Replace function works but you can always use:
BOOL GetImageInfo( int nImage, IMAGEINFO* pImageInfo)
to change the image list directly, don't forget to delete previous bitmap if you plan to use it.
4. You may want to take a look at these ImageList macros:
ImageList_Create, ImageList_LoadImage, ImageList_AddMasked, etc
Thank you and good luck
- God bless the World
|
|
|
|
|
Ok..mm... where do i start.
I downloaded the skinstyle source and example app from the codeproject (controls>dialogs and windows>advanced UI and skins). I compiled the example and it worked fine. I wanted to export the project to another compiler (the mingw, Dev-C++ IDE, www.bloodshed.net) because this seems to make the final executables smaller, i also dont know why: if you write a simple app which shows a window it is about 5kb in mingw and 24kb in Visual C++. Anyways, i copied the code exactly as in the visual c++ project of the skinstyle example but then i get linker errors like:
main.cpp: undefined reference to `SkinDialog::LoadSkin(char *)'
I had these errors before in other apps and i believe they are caused by a missing object file (.lib, .a) right? I included the .lib file from the skinstyle project in my app and the other necessary lib files but it still gives me those errors. Anyone know why? Does anyone know how to compile the project under mingw?
Kuniva
|
|
|
|
|
I have created a print preview window using a CRichEditCtrl. Every thing is working great. I know where the start and end of my pages and where my page headers and footers are. But can someone help me with How to draw a line in the control. I have tried getting the CDC of the control and using drawline but that does not seem to work either.
thank you.
|
|
|
|
|
Hi
I have tooltips (CToolTipCtrl) over an Edit box. Normaly this tooltip appears according to the mouse pointer.
Do You know ?
1) How can I move top left corner of the tooltip into the top left corner of the edit box associated?
2) How can I change the height of the tooltip into the height of edit box associated?
Thank you very much
|
|
|
|
|
Hi
I have several documents in my MFC project, and when a start my program i get a dialog
box which let me choose which document type I want to use.
How do I get hold of that Dialog box so that I could modify it?
best regards
//Fredrik
|
|
|
|
|
Hi,
I've been chasing a solution to this in newsgroups etc. for the best part of a year without a single response. Using VC++ 6 SP5 on Win89. VS won't allow add-ins to start and reports that each add-in's server object couldn't be started. One or two did work for a while but none do now. Any ideas?
|
|
|
|
|
Hello Gary,
Do you have Visual C++ 5.0 installed on your machine ? If so, make sure that all add-ins (with the same version) are installed for both VC++ 6.0 and VC++ 5.0.
A few weeks ago, I had the same problem. One of my add-ins was a newer version and I got it installed for my Visual C++ 6.0. It won't start up. I then installed the same version for my VC++ 5.0. Things worked.
Best of luck, Gary,
Bio.
|
|
|
|
|
My boss likes data displayed in disabled edit boxes (ugh!), however recentily I have been badgered to adapt the edit box so that if, the amount of text in the box necessiates a Scroll Bar being displayed, one will automatically appear, otherwise if there is not enough text to necessiate a scrollbar, none is shown.
Is there any easy way of achieving this.
Regards
Ray
"Je Suis Mort De Rire"
|
|
|
|
|
One thing you may want to try is to change the style of your control to
Read Only. The control may still get the focus so the user can view all
data by using the arrow keys. By disabling a window, the scrollbar too is
disabled.
- God bless the World
|
|
|
|
|