Hi I am developing using C/C++ window application using winapi. I will be using some standard STL containers and some win api functions provided by windows.h. I would like use the app on different windows versions such as windows 7 and 10. The apps will be builded for x86 architecture. Would I be getting any issues if app are run on x64? The apps wont need any permissions to access restricted folders. At the moment I am not getting any issues running on windows 7. I am just thinking about common possible pitfalls.

Member Avatar
Member Avatar
+0 forum 3

Hi I am trying to get windows positioned in specific order as show below ![desired.PNG](/attachments/large/3/6447240b1491d04046fa904f31659f9b.PNG) but I am unable to get and get always this ![wrong.PNG](/attachments/large/3/71f4b92c4f40a6afeeab7e3c2f136526.PNG) the code below is shown HDWP cmdWnds; cmdWnds = BeginDeferWindowPos(col.size()); for (int i = 0; i < col.size(); i++) { if (i == 0) { if (DeferWindowPos(cmdWnds, col[i], HWND_NOTOPMOST, x_pos_start_pr + i * x_offset_pr, y_pos_start_pr + i * y_offset_pr, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW) == NULL) return ERROR; } else { if (DeferWindowPos(cmdWnds, col[i], col[i - 1], x_pos_start_pr + i * x_offset_pr, y_pos_start_pr + i * y_offset_pr, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW) == NULL) …

Member Avatar
+0 forum 0

Hi Dw. I'm new to C++ nor Win32 app dev. I want my app to stay open or running even if I'm not interacting with it. And how to write a close call. In VB to close it you just right: Close() How can I achieve these two? Also how to remove the title bar as well with those 3 buttons(minimize,maximize,close)?

Member Avatar
Member Avatar
+0 forum 1

I'm getting "error C2039: 'AllocSysString' : is not a member of 'System::Char' error. I'm trying to assign the result to a string variable. wchar_t str; return str.AllocSysString(); But I'm getting the above error.

Member Avatar
Member Avatar
+0 forum 3

OK so I'm using the function SetDlgItemText() to change the text in a static text control of my window. Problem is, when it updates from a longer string to a shorter string ("Sup Y'all" -> "Hi"), the previous, longer string persists leaving "Hip Y'all". However, remaining bit of the old string disappears once I move it out off the screen. I think it has to do something with the entire window not updating properly. Any ideas on how to fix this? thanks

Member Avatar
Member Avatar
+0 forum 1

Creating WinAPI windows and controls can be a pain and quite difficult/annoying at times. Most of the time, I find myself searching MSDN, DaniWeb, and StackOverflow. I hate having to use external libraries unless I absolutely have no other choice. Below contains code for creating WinAPI windows, Controls, Sub-Classing, and EventHandling for each control. There is a sample working code below this article and an image of what the sample code produces. There are only 4 files to include to your projects: Form.hpp -- Form.cpp Controls.hpp -- Controls.cpp The code for these files are as follows: Form.hpp: #ifndef FORM_HPP_INCLUDED #define …

Member Avatar
Member Avatar
+0 forum 5

i want to know that how can we keep an eye on one process that its alive or terminated , actually i have service which will always check my process if my process terminated then service will start it again so i want to know how to check process status using winapi , asume i have process pid so how to keep checking its status thanks

Member Avatar
Member Avatar
+0 forum 3

i write one windows service working perfect , but when i check it in windows services list then its description tab is empty so i thought to add description to it , but do not know how to add description to it , so any body have any idea how to add description to windows service in c++

Member Avatar
Member Avatar
+0 forum 2

For getting the share folder name i have been used the following code , here i am able to get the folder names . But the problem what i am facing is along with the share folder created by the user it gives some extra folder also , i don't know how to prevent the programe to hide that unnecessary folder names . Like in my case i am getting "cc_views"(used for clearcase) and "Users" folders , which i want to remove from my folder lists . I wrote the following codes , Please help in getting the correct output …

Member Avatar
Member Avatar
+0 forum 1

Hello, I was partaking in the global game jam (where you have to try to make a game in 48 hours). I got my game pseudo-finished, but I cannot get it to render the scene properly. Here is the code related to the rendering: Code for opengl initialization: glClearColor(0.5f,0.5f,0.5f,1.0f); float ambLight[]={0.5f,0.5f,0.5f,1.0f}; glLightfv(GL_LIGHT1,GL_AMBIENT,ambLight); glEnable(GL_LIGHT1); LoadTextures(); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); Code for opengl drawing (called every frame): glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(FOV,(double)winWidth/(double)winHeight,NEAR_RENDER,FAR_RENDER); glMatrixMode(GL_MODELVIEW); glViewport(0,0,winWidth,winHeight); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glRotatef(dty,1.0f,0.0f,0.0f); glRotatef(dtx,0.0f,1.0f,0.0f); glTranslatef(-x,PLAYER_HEIGHT_STAND, -y); glBindTexture(GL_TEXTURE_2D,wall[level]); glColor3f(1.0f,1.0f,1.0f); //... glBindTexture(GL_TEXTURE_2D,ground); for (int yy=0; yy<mazeDimy; ++yy) { for (int xx=0; xx<mazeDimx; ++xx) { glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f); glVertex3f(xx*WALL_LENGTH,FLOOR_HEIGHT,yy*WALL_LENGTH); glTexCoord2f(0.0f,1.0f); glVertex3f(xx*WALL_LENGTH,FLOOR_HEIGHT,(yy+1)*WALL_LENGTH); glTexCoord2f(1.0f,1.0f); …

Member Avatar
Member Avatar
+0 forum 8

Hi all, Am building a WinAPI project in Code::blocks and MinGW. I Downloaded some opensource source code, and tried to compile the snippet haveing done nothing to it, and I get *Syntax Error on line 6* for the following code: IDR_MENU MENU DISCARDABLE {//BEGIN POPUP "File" {//BEGIN MENUITEM "New", IDM_NEW MENUITEM "Open", IDM_OPEN MENUITEM "Save", IDM_SAVE MENUITEM SEPARATOR MENUITEM "Exit", IDM_EXIT }//END POPUP "&Options" {//BEGIN MENUITEM "&Show Toolbar", ID_OPTIONS_SHOWTOOLBAR , CHECKED }//END }//END If needed I could try to find the link to the entire program source I've downloaded. What stumps me as that I have done nothing to the …

Member Avatar
Member Avatar
+0 forum 4

hello everyone..i'm trying to create a simple window using Win API in visual studio 2010 using the code below #include <Windows.h> LPCTSTR g_lptstrClassName="myWindowClass"; LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd,msg,wParam,lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG msg; wc.cbSize=sizeof(WNDCLASSEX); wc.style=0; wc.lpfnWndProc=WndProc; wc.cbClsExtra=0; wc.cbWndExtra=0; wc.hInstance=hInstance; wc.hIcon=LoadIcon(NULL,IDI_APPLICATION); wc.hCursor=LoadCursor(NULL,IDC_ARROW); wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName=NULL; wc.lpszClassName=g_lptstrClassName; wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL,"Registration Failed!!","Error!",MB_ICONEXCLAMATION|MB_OK); return 0; } MessageBox(NULL,"Registration successful!!!","OK",MB_OK); hwnd=CreateWindowEx(WS_EX_CLIENTEDGE,g_lptstrClassName,"TITLE",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT, 240,120,NULL,NULL,hInstance,NULL); if(hwnd==NULL) { MessageBox(NULL,"Window Creation Failed!","Error",MB_ICONEXCLAMATION|MB_OK); return 0; } ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg,NULL,0,0)>0) { TranslateMessage(&msg); DispatchMessage(&msg); } …

Member Avatar
Member Avatar
+0 forum 2

Hey all, I am working on a project with an FPGA but I need serial communication between the FPGA and the desktop since the memory of the FPGA is limited and I need to be able to send longer inputs to the FPGA by using buffers on the desktop. After hours of browsing and reading, I still can't figure out why my code isn't working. I saw similar code snippets on different websites, but I can't seem to get the serial communication to work. The writing part is working (probably), but the reading goes wrong. Every 'real character' is followed …

Member Avatar
+0 forum 0

Hi gueys, I have question searched in google but without something that can help. **How to get the binary stream from files ( especially executable files) using winapi (CreateFile , etc)????** I learned in these days how to read write files using Createfile, ReadFile, WriteFile , etc and all these WINAPI functions. But ReadFile get me characters contains of files, and when I want to read exe files it get me a few bytes and that's it. The reason of this behaviour is that the readfile read the file until get NULL and as you know the exe files have …

Member Avatar
Member Avatar
+0 forum 10

Hi All, Why my QueueUserWorkItem is not at all working. My code is here: [CODE] typedef struct { PCHAR URL[MAX_URL] ; PCHAR DestinationPath ; }MAINDATA, *PMAINDATA ; int main(int argc, char * argv[]) { PMAINDATA pData ; BOOL bQuwi ; DWORD dwIndex ; PCHAR pURL ; pData = (PMAINDATA)malloc(sizeof(MAINDATA)) ; pData->DestinationPath = NULL ; pData->URL[0] = 0 ; do { if(argc < 3) { printf("Main Error-> Not Enough Arguments\n") ; break ; } printf("START\n") ; pData->DestinationPath = argv[2] ; while((pURL = (PCHAR)GetNext_FileList(pContext)) != NULL) { TempURL = StrDupA(pURL) ; pData->URL[dwIndex] = (PCHAR)TempURL ; dwIndex++ ; } dwTotalNumberOfURL = dwIndex ; …

Member Avatar
Member Avatar
+0 forum 1

ok. so i'm having trouble with the Windows API. i'm just learing how to use it, so i don't know much about it. anyways, i just wanted to create a window and have it displayed then catch the exit message and close, but VC Compiler is throwing errors. 1>c:\users\furrix\documents\visual studio 2008\projects\test\test\test.cpp(9) : error C2144: syntax error : 'int' should be preceded by ';' 1>c:\users\furrix\documents\visual studio 2008\projects\test\test\test.cpp(24) : error C2065: 'WindowProc' : undeclared identifier 1>c:\users\furrix\documents\visual studio 2008\projects\test\test\test.cpp(32) : error C2664: 'CreateWindowExW' : cannot convert parameter 10 from 'HINSTANCE' to 'HMENU' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast …

Member Avatar
Member Avatar
+0 forum 5

I have read [URL="http://bytes.com/topic/c/answers/891582-radio-button-groupbox-not-generating-wm_command"]http://bytes.com/topic/c/answers/891582-radio-button-groupbox-not-generating-wm_command[/URL] but when I try: [CODE] hwndFrame = CreateWindow( "BUTTON", "Test", WS_CHILD | WS_VISIBLE | BS_GROUPBOX | WS_CLIPCHILDREN, 304, 112, 233, 63, hwnd, NULL, g_hInst, 0); if(hwndFrame == NULL) return 0; hwndBtnCerrar = CreateWindow( "BUTTON", "Close", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 20, 20, 103, 17, hwndFrame, (HMENU)IDBTNCERRAR, g_hInst, 0); if (hwndBtnClose == NULL) return 0; GroupBoxProc = (WNDPROC)GetWindowLongPtr(hwndFrame, GWLP_WNDPROC); SetWindowLongPtr(hwndFrame, GWLP_WNDPROC, (LONG_PTR)(GroupRelay)); [/CODE] The button works fine, but I the problem it's that is was all in vain because the frame doesn't appear, so how could I do to see the Group Box and enable the "Close" button? Any help would …

Member Avatar
+0 forum 0

Hello, I have been struggling with this for hours now. Is there any way to completely remove the icon that is displayed in the upper left corner of a window in WPF, without setting the window style to ToolWindow? I have tried loading user32 and setting various WinAPI-styles with no success. It worked with setting the style to WS_EX_DLGMODALFRAME until I attached an icon to the assembly itself. Thank you.

Member Avatar
Member Avatar
+0 forum 5

Hi, I have an array of hWnds, and I need to change each one of their background colors. They're all without a border(titlebar, and such). I've searched Google, and IxQuick, and I need an answer please. Thanks so much for the help.

Member Avatar
Member Avatar
+0 forum 3

I am developing a network chat application, I am using Winapi, my main window is a dialog (created from a .rc file). I am looking into a way of doing an text box where my outuput text can be like this: [QUOTE] [COLOR="Green"]Welcome to ##### chat server![/COLOR] [COLOR="Red"]Person1[/COLOR] says: Hi folks, what's up? [COLOR="Red"]Person2[/COLOR] says: Hey... that's Person1! [COLOR="Green"]*Person2 pokes Person1.*[/COLOR] [COLOR="Red"]Person1[/COLOR] says: Hey![/QUOTE] I'm using a simple EDIT TEXT control ATM. I've been trying to implement a RICH EDIT CONTROL but it seems to be very hard to do... Anyone know of a good way to obtain the result …

Member Avatar
Member Avatar
+0 forum 3

Hi everybody, this text turned out to be rather long and maybe not so clear, please excuse me. I'm currently using the winsock library to send and receive data in an application made with WinAPI, I'm not using MFC. I'm using asynchronous sockets (I think that's what it's called) which means that I will get a userdefined message posted in my message loop whenever there is data to read, a connection to accept etc. I'm sending my data using TCP. Now I want to write a dynamic recv handler and by that I mean a function that can receive (almost) …

Member Avatar
+0 forum 0

I'm using Dev-c++ to make a dialog-based app. I had it working, but now I am getting an error: An Access Violation (Segmentation Fault) raised in your program. I have narrowed it down to the winmain function: [CODE]int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) { if (iCmdShow > 4) { commandlineopener=szCmdLine; } gCmdShow=iCmdShow; strcat(about,version); strcat(about,"Stuff"); //About stuffs go here DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), 0,(DLGPROC)MainDlgProc); WSACleanup(); return 0; }[/CODE] What am I doing wrong?

Member Avatar
Member Avatar
+0 forum 4

Hello I'm trying to make a window with Windows API. Whenever I run my application, the buttons look like Windows 98 buttons. How do I make the buttons look like XP buttons on Windows XP and Win7 buttons on Windows 7? My compiler is Mingw. [CODE]CreateWindowEx( 0, "BUTTON", "OK", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON 10, 10, 50, 25, hwnd, (HMENU)com, hInstance, NULL ); [/CODE]

Member Avatar
Member Avatar
+0 forum 4

Hey everybody, I am currently having difficulty using GetOpenFileName() and GetSaveFileName(). The keeps returning the error " undefined reference to `_GetOpenFileNameA@4' ". I can't seem to find a fault in my code, so is it the compiler or is it the code? I am using CodeBlocks. [CODE]void DoFileOpen(HWND hwnd) { OPENFILENAME ofn; char szFileName[MAX_PATH] = ""; // Buffer in which the filename will be placed ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwnd; ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = "txt"; if(GetOpenFileName(&ofn)) { HWND hEdit …

Member Avatar
Member Avatar
+0 forum 3

Hey guys, I've recently started learning WinAPI and I want to make a Tic Tac Toe game with it but I have a problem I have a main window ("field") and 9 child windows ("tiles") and I want to make the tiles clickable so that a click calls the Beep() function. I also want to make each tile able to call Beep() only once (just like you can put a cross only once in the tile in tic tac toe). So I have this code: [CODE=c]#include <windows.h> LPCWSTR FldClass = L"FieldClass"; LPCWSTR TileClass = L"TileClass"; LRESULT CALLBACK MainProc(HWND, UINT, WPARAM, …

Member Avatar
Member Avatar
+0 forum 9

Hello everybody, I am currently developping a GUI interface game for windows XP. I am currently having difficulty changing the background of a EDIT box created with CreateWindowEx(). It's default background is white (which is the color I want). But the user is not supposed to be able to adjust the text within that EDIT box so I added a WS_DISABLED, but then the background color changes into gray and the text color into dark gray. How do I change that? This is a part of the switch(Message) in the the WndProc() function, the case WM_CREATE: [CODE] /* Creating box …

Member Avatar
Member Avatar
+0 forum 3

Hi. I have a richedit control and when dropping text from another control I would like to change the format of that text. I wonder which messages I should trap or how to do this in plain Winapi. (I have already subclassed the pasting message) Thank you.

Member Avatar
+0 forum 0

Hello, I'm trying to get from the screen, the region, or rectangle (the coordinated) of the part that is being painted. For example when I move some window or I have some action on the screen I want to get only that part of the screen image that is being painted (because it changed). I try calling it inside WM_PAINT event before BeginPaint(). [CODE] LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { [...] case WM_PAINT:{ RECT rectUpd; if(hwnd!=NULL){ char s[100]=""; //hDesktop is desktop windown handler - GetDC(GetDesktopWindow()); GetUpdateRect (hDesktop, &rectUpd, FALSE); c++; sprintf(s,"Top:%d Left:%d Right:%d …

Member Avatar
Member Avatar
+0 forum 17

The End.